ios8 swift开发:let var 差别讨论
localhost:~ hejiasheng$ xcrun swift
Welcome to Swift! Type :help for assistance.
1> var a:Int
a: Int = 0
2> let b:Int
<REPL>:2:5: error: 'let' declarations require an initializer expression
let b:Int
^
2> let b = 5
b: Int = 5
3> b = 6
4> println(6)
6
5> println(b)
6
非常多地方说 let 变量不能改变。我測试发现能够改变。
但定义时候须要 初始化。

playground 情况下。会报错。 能负值。
浙公网安备 33010602011771号