Enumeration
-
์ฐ๊ด๋ Value๋ค์ ๊ณตํต Type์ ์ ์ํ ๊ฒฝ์ฐ ์ฌ์ฉ
-
Type-Safeํ ๋ฐฉ๋ฒ์ผ๋ก ์ฌ์ฉ ๊ฐ๋ฅ
-
ํน์ ๊ฐ์ผ๋ก Raw Value ์ง์ ํ์ ์๋
-
Raw Value ์ฌ์ฉ ๊ฐ๋ฅ ์๋ฃ ๊ตฌ์กฐ
- String
- Chracter
- Integer
- Floating-point
-
์ฌ์ฉ ๊ฐ๋ฅ ๊ธฐ๋ฅ
- Computed Property
- Instance method
- Initializer
- Extension
- Protocol
-
Raw Value์ ๋ฌต์์ ํ ๋น
enum Planet: Int { case mercury = 1, venus, earth, mars, jupiter, saturn, uranus, neptune // 2, 3, 4, 5, 6, 7, 8 } enum CompassPoint: String { // RawValue type String์ผ๋ก ์ง์ ์ case north, south, east, west // member ์ด๋ฆ์ด RawValue๊ฐ ๋จ }
-
Iterating
CaseIterable
Protocol
-
Associated Values
-
member์ ์ฐ๊ด๋ ๊ฐ์ ์ ์ฅํ ์ ์์
-
๊ฐ๊ฐ์ member์ ๋ฐ๋ฅธ ๋ค๋ฅธ ํํ์ ๊ฐ์ ์ ์ฅํ ์ ์์
- tuple ์ง์์ผ๋ก ์ฌ๋ฌ๊ฐ ๊ฐ๋ ๊ฐ๋ฅ
-
Associated Value ์ฌ์ฉ์ enum์ Raw Value type ์ง์ ๋ถ๊ฐ
enum Barcode { case upc(Int, Int, Int, Int) case qrCode(String) }
-
Optional๋ Enum์
-