Page 106

18. Swift – Enumerations

Swift

An enumeration is a user-defined data type which consists of set of related values. Keyword enum is used to defined enumerated data type.

Enumeration Functionality Enumeration in swift also resembles the structure of C and Objective C. 

It is declared in a class and its values are accessed through the instance of that class.

Initial member value is defined using enum intializers.

Its functionality is also extended by ensuring standard protocol functionality.

Syntax Enumerations are introduced with the enum keyword and place their entire definition within a pair of braces: enum enumname { // enumeration values are described here } For example, you can define an enumeration for days of week as follows: enum DaysofaWeek { case Sunday case Monday --case Saturday }

Example enum names{ case Swift case Closures } var lang = names.Closures lang = .Closures 94

​Quick is just a powerful and spontaneous programming language for macOS, iOS, watchOS and tvO...  

...