添加了一些基本类型介绍
This commit is contained in:
parent
d68697b576
commit
a6b27c3f64
|
@ -28,4 +28,23 @@ let b = 3.1415926
|
||||||
let c = 'a'
|
let c = 'a'
|
||||||
|
|
||||||
// s为string类型
|
// s为string类型
|
||||||
let s = "abc"
|
let s = "abc"
|
||||||
|
|
||||||
|
// F#还提供了一些集合类型,比如列表, 数组和序列
|
||||||
|
|
||||||
|
// 列表: [1; 2; 3; 4]或者['a'; 'b'; 'c'; 'd']
|
||||||
|
// 列表是一个有序的、不可变的同类型元素系列, 并且以分号分割
|
||||||
|
|
||||||
|
let list = ["第一个元素"; "第二个元素"; "第三个元素"]
|
||||||
|
|
||||||
|
printfn "%A" list
|
||||||
|
// 我们将其输出,结果应该为["第一个元素"; "第二个元素"; "第三个元素"]
|
||||||
|
|
||||||
|
// 数组与列表类似, 有序的同元素系列, 不同点是数组是可变的
|
||||||
|
// 并且左右两边多了两根竖线
|
||||||
|
|
||||||
|
let array = [| "数组第一个元素"; "数组第二个元素" |]
|
||||||
|
|
||||||
|
printfn "%A" array
|
||||||
|
|
||||||
|
// 当然也有一些表达某种特定结构的类型,比如元组, 记录, 结构, 类, 接口, 枚举, 可区分联合
|
Loading…
Reference in New Issue