var 字符数组 = ["d","cd","bcd","abcd","abc","ab","a"]
sorted(字符数组, {count($0) == count($1) ? $0 < $1 : count($0) < count($1)})
sorted(字符数组, {count($0) == count($1) ? $0 < $1 : count($0) < count($1)})
2015-05-08
var 字符数组 = ["d","cd","bcd","abcd","abc","ab","a"]
sorted(字符数组, {(n1:String,n2:String)->Bool in
return count(n1) == count(n2) ? n1 < n2 : count(n1) < count(n2)
}
)
sorted(字符数组, {(n1:String,n2:String)->Bool in
return count(n1) == count(n2) ? n1 < n2 : count(n1) < count(n2)
}
)
2015-05-08
声明函数:swap( inout a:Int , inout b:Int )
调用: swap(&x , &y)
调用: swap(&x , &y)
2015-05-05
最后的替换可以简写成
let index2 = advance(str6, 15)
let index3 = advance(str6, 50)
str.replaceRange(index2..<index3, with: "111111111111")
原来是:str.stringByReplacingCharactersInRange(Range<String.Index>(index2..<index3), withString: "111111111")
let index2 = advance(str6, 15)
let index3 = advance(str6, 50)
str.replaceRange(index2..<index3, with: "111111111111")
原来是:str.stringByReplacingCharactersInRange(Range<String.Index>(index2..<index3), withString: "111111111")
2015-05-02