Write a Switch-Case statement

 Problem

I have a list of different conditions and want to write a Switch-Case statement.



 Recipe



let name = "John"

switch name {
    // List the different cases
    // - no "break" needed
    
    case "John" : print("Hello John!")
    case "Jane" : print("Hello Jane!")
    default     : print("Hello!")
}

				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground