Swift 4 - Useful Information - Control Flow & Collections
Conditional Statements The if Statement The most basic if statement contains a single if condition, and executes a set of statements only if that condition is true: var temp = 25 if temp <= 30 { print("It's cold.") } You can specify additional conditions by chaining together multiple if statements. if cardValue == 11 { print("Jack") } else if cardValue == 12 { print("Queen") } else { print("Not found") } The switch Statement Each case begins with the keyword case : switch distance { case 0: print("not a valid distance") case 1,2,3,4,5: print("near") default: print("too far") } Swift doesn't require break statements, but will still accept one to match and ignore a particular case, or to break out of a matched case before that case has completed its execution. Where The where clause checks for additional conditions. let myPoint = (1, -1) switch myPoint { cas...