Swift4.0复习整数,浮点数,布尔值
1.类型相互转换:
Int(a)
Float(b)
let a = Bool(truncating: NSNumber(value: c))
2.元组:
let tuple: (Int, String, Bool) = (10, 'sisi', true)
let tuple2 = (int: 5, double: 3.5, bool: true)
let c = tuple2.int
空元祖:
// 声明一个Void类型的常量v
let v: Void
// 用空元组对v初始化
v = ()
3.集合类型:
1> 数组:
2> 集合Set:
3> 字典:
4> 范围操作符:
let doubleRange = 1.0 ... 3.0
let stringRange = "aaa" ... "ccc"
5> 单边范围操作符:
let sub1 = array[2...]
let sub2 = array[...3]
let sub3 = array[..<3]