#15: Comparing Raw Values
Question
// Swift Quiz
— objc.io (@objcio) May 29, 2019
enum Foo: RawRepresentable {
case one
case two
init?(rawValue: Int) {
self = .one
}
var rawValue: Int {
return 1
}
}https://t.co/FJWDSNPQGc == Foo.two
// What's the result?
Solution
Solution: true
— objc.io (@objcio) May 30, 2019
The equality operator uses the raw value to compare whether two cases are equal.https://t.co/s7500CWmAg