add list, modify a to -3
This commit is contained in:
@ -96,14 +96,14 @@ Swift 是一个类型安全的语言,可选就是一个很好的例子。Swift
|
||||
let languageName = "Swift"
|
||||
languageName = "Swift++"
|
||||
// this is a compile-time error - languageName cannot be changed
|
||||
|
||||
|
||||
### 输出常量和变量
|
||||
|
||||
你可以用`println`函数来输出当前常量或变量的值:
|
||||
|
||||
println(friendlyWelcome)
|
||||
// prints "Bonjour!"
|
||||
|
||||
|
||||
`println`是一个用来输出的全局函数,输出的内容会在最后带换行。如果你用Xcode,`println`将会输出内容到“console”面板上。(另一种函数叫`print`,唯一区别是在输出内容最后不会加入换行。)
|
||||
|
||||
`println`函数输出传入的`String`值:
|
||||
@ -117,7 +117,7 @@ Swift用字符串插值(string interpolation)的方式把常量名或者变
|
||||
|
||||
println("The current value of friendlyWelcome is \(friendlyWelcome)")
|
||||
// prints "The current value of friendlyWelcome is Bonjour!
|
||||
|
||||
|
||||
> 注意:字符串插值所有可用的选项在 字符串插值 这章中讲述。
|
||||
|
||||
### 注释
|
||||
@ -131,9 +131,9 @@ Swift 中的注释与C 语言的注释非常相似。单行注释以双正斜杠
|
||||
|
||||
/* this is also a comment,
|
||||
but written over multiple lines */
|
||||
|
||||
|
||||
与C 语言多行注释不同的是,Swift 的多行注释可以嵌套在其它的多行注释之中。你可以先生成一个多行注释块,然后在这个注释块之中再嵌套成第二个多行注释。终止注释时先插入第二个注释块的终止标记,然后再插入第一个注释块的终止标记:
|
||||
|
||||
|
||||
/* this is the start of the first multiline comment
|
||||
/* this is the second, nested multiline comment */
|
||||
this is the end of the first multiline comment */
|
||||
@ -145,4 +145,164 @@ Swift 中的注释与C 语言的注释非常相似。单行注释以双正斜杠
|
||||
|
||||
let cat = "🐱"; println(cat)
|
||||
// prints "🐱"
|
||||
| ||||