December 2018
Intermediate to advanced
414 pages
10h 19m
English
The first method to declare a conformance is to do it at the top level, when you declare your custom type. You'll notice that the raw representation comes first, then the protocol conformance:
enum State: Int, Toggling { case off = 0 case on mutating func toggle() { self = self == .on ? .off : .on }}var state: State = .onstate.toggle()assert(state == .off)
Read now
Unlock full access