Swift: Initializing from rawValue

When we define a enumeration with a raw value type, Swift provides a default initializer that takes the value of that type’s raw value as a parameter and return a enumeration case or nil. Not all raw values will find a matching case in enumeration.

Swift code

 

Leave a Reply