Page 107


switch lang { case .Swift: println("Welcome to Swift") case .Closures: println("Welcome to Closures") default: println("Introduction") } When we run the above program using playground, we get the following result: Welcome to Closures Swift enumeration does not assign its members default value like C and Objective C. Instead the members are explicitly defined by their enumeration names. Enumeration name should start with a capital letter (Ex: enum DaysofaWeek). var weekDay = DaysofaWeek.Sunday Here the Enumeration name 'DaysofaWeek' is assigned to a variable weekday.Sunday. It informs the compiler that the datatype belongs to Sunday will be assigned to subsequent enum members of that particular class. Once the enum member datatype is defined, the members can be accessed by passing values and further computations.

Enumeration with Switch Statement Swift 'Switch' statement also follows the multi way selection. Only one variable is accessed at a particular time based on the specified condition. Default case in switch statement is used to trap unspecified cases. enum Climate{ case India case America case Africa case Australia }

var season = Climate.America season = .America switch season { 95

​Quick is really a powerful and intuitive programming language for macOS, iOS, watchOS and tvO...