Update a_swift_tour.md
“In an if statement, the conditional must be a Boolean expression—this means that code such as if score { ... } is an error, not an implicit comparison to zero.” 译文中 “not an implicit comparison to zero”未做翻译。
This commit is contained in:
@ -80,7 +80,7 @@
|
||||
}
|
||||
teamScore
|
||||
|
||||
在`if`语句中,条件必须是一个布尔表达式——像`if score { ... }`这样的代码是错误的。
|
||||
在`if`语句中,条件必须是一个布尔表达式——这意味着像`if score { ... }`这样的代码将报错,而不会隐形地与 0 做对比。
|
||||
|
||||
你可以一起使用`if`和`let`来处理值缺失的情况。有些变量的值是可选的。一个可选的值可能是一个具体的值或者是`nil`,表示值缺失。在类型后面加一个问号来标记这个变量的值是可选的。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user