File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
swift-6-beta.docc/LanguageGuide Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
* 枚举* 为一组相关的值定义了一个共同的类型,并使你能够以类型安全的方式在代码中使用这些值。
6
6
7
- 如果你对 C 语言很熟悉,你会知道 C 的枚举将相关的名称分配给一组整数值。Swift 中的枚举更加灵活,不必为每一个枚举成员提供一个值。如果给枚举成员提供一个值(称为* 原始* 值),则该值的类型可以是字符串、字符,或是一个整型值或浮点数 。
7
+ 如果你对 C 语言很熟悉,你会知道 C 的枚举将相关的名称分配给一组整数值。Swift 中的枚举更加灵活,不必为每一个枚举成员提供一个值。如果给枚举成员提供一个值(称为* 原始* 值),则该值的类型可以是字符串、字符,或是一个整数或浮点数 。
8
8
9
9
此外,枚举成员可以指定* 任意* 类型的关联值存储到枚举成员中,就像其他语言中的联合体(unions)或变体(variants)。每一个枚举成员都可以有适当类型的关联值。
10
10
@@ -154,7 +154,7 @@ case .west:
154
154
155
155
你可以这样理解这段代码:
156
156
157
- “判断 ` directionToHead ` 的值。当它等于 ` .north ` 时,打印 ` “Lots of planets have a north” ` 。当它等于 ` .south ` 时,打印 ` “ Watch out for penguins” ` 。”
157
+ “判断 ` directionToHead ` 的值。当它等于 ` .north ` 时,打印 ` “Lots of planets have a north” ` 。当它等于 ` .south ` 时,打印 ` " Watch out for penguins" ` 。”
158
158
159
159
……以此类推。
160
160
@@ -482,7 +482,7 @@ let sunsetDirection = CompassPoint.west.rawValue
482
482
483
483
``` swift
484
484
let possiblePlanet = Planet (rawValue : 7 )
485
- // possiblePlanet is of type Planet? and equals Planet.uranus
485
+ // possiblePlanet 类型为 Planet? 值为 Planet.uranus
486
486
```
487
487
488
488
<!--
You can’t perform that action at this time.
0 commit comments