1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import UIKit //if let age = 7 if age < 3 { print("Baby") } else if age >= 3 && age < 20 { print("child") } else{ print("adult") } //Switch switch age { case 1..<3:print("Baby") case 3..<20:print("Child") default : print("Adult") } switch age { case 0,3,11,12 :print("Baby") case 4...10:print("Child") default : print("Adult") } | cs |
'IOS > Swift 문법' 카테고리의 다른 글
7. class (0) | 2016.05.20 |
---|---|
6. Functions (0) | 2016.05.20 |
4. Control Flow (0) | 2016.05.20 |
3. Dictionary (0) | 2016.05.19 |
2. Array (0) | 2016.05.18 |