Swift
[Swift] Enum - Associated Values and Raw Values
insub4067
2022. 11. 21. 13:18
Enumerations — The Swift Programming Language (Swift 5.7)
Enumerations An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code. If you are familiar with C, you will know that C enumerations assign related names to a set of in
docs.swift.org
enum 을 쓸때 케이스 마다 다른 타입을 만들수도 있고 모든 케이스가 동일한 타입을 리턴하게 할수도 있다.
케이스 마다 다른 타입 -> associated values
모든 케이스가 동일한 타입 -> raw values