April 2017
Intermediate to advanced
316 pages
9h 33m
English
Enumeration members can come prepopulated with default values (called raw values), which are all the same type. The following example presents an incomplete HttpErrorenum with raw values:
enum HttpError: Int { case badRequest = 400 case unauthorized = 401 case forbidden = 403 }
In the preceding example, the raw values for enum called HttpError are defined to be of the Int type and are set to some of their integer code.
Raw values can be of String, Character, Int, or any floating number types. Each raw value must be unique within its enumeration declaration.
Raw values are set to prepopulated values when we first define the enumeration such as HttpError in the preceding example; therefore, the raw value for an enumeration case ...
Read now
Unlock full access