Skip to content

Commit ab317f9

Browse files
committed
完成'分号'部分翻译
Signed-off-by: mrahmiao <mrahmiao@gmail.com>
1 parent 3176244 commit ab317f9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

zh_style_guide.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,27 @@ var myClass = MyModule.MyClass()
152152
}
153153
```
154154

155+
## 分号
155156

157+
Swift中,每条语句后的分号都不是必需的。只有在一行中有多条语句时才需要添加上分号。
158+
159+
请不要在一行中写上用分号隔开的多条语句。
160+
161+
这条规则的唯一例外就是`for-conditional-increment`结构,该结构中分号是必需的。不过,请尽可能地使用另外一种结构,`for-in`循环。
162+
163+
**优选:**
164+
```swift
165+
var swift = "not a scripting language"
166+
```
167+
168+
**不建议使用:**
169+
```swift
170+
var swift = "not a scripting language";
171+
```
172+
173+
**请注意**:Swift与JavaScript不同, 在后者中省略分号[通常是不安全的](http://stackoverflow.com/questions/444080/do-you-recommend-using-semicolons-after-every-statement-in-javascript)
174+
175+
## 类与结构体
156176

157177

158178
[objc-style-guide]: https://github.com/raywenderlich/objective-c-style-guide

0 commit comments

Comments
 (0)