#36: Custom Raw Values
Question
// Swift Quiz
— objc.io (@objcio) October 30, 2019
enum Skill: Int {
case swiftUI, combine, arkit = 4, uikit
subscript(n: Int) -> Skill? {
return Skill(rawValue: n)
}
}
let skill = Skill.uikit.rawValue
// What’s the value of skill?
Solution
Solution: 5
— objc.io (@objcio) October 31, 2019
When we provide a custom raw integer value for a case, Swift continues numbering the next cases from the next integer onwards.https://t.co/s7500CWmAg