标签:
Swift 好多新奇的地方啊。。。妈的
var display: int {
get()
set()
}
Tuple:
let x: (d:Double, e:String, f:Int) = (3.1415, "Hello", 1)
x.d x.e x.f
let (a,b,c) = x
print(a,b,c)
Range:
let array=["a","b","c","d","e"]
let subArray1 = array[2...4] // c d e
let subArray2 = array[2..<4] // c d
比python的字符串[::]还是要差一点
for lop in 1...100 //打印从1到100
swift里的class是传引用的(和java一样),函数等可以更改传入类的成员的值
class foo { var value:Int = 100 } func add (f: foo) { f.value += 1 } let test = foo() add(test) test.value
Array:
var a = Array<String>()
or
var a = [String]()
filter map reduce
Dictionary
var dic = Dictionary<String, Int>()
var dic = [String: Int]()
标签:
原文地址:http://www.cnblogs.com/makejeffer/p/5493206.html