You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letage1=12letage2=21if age1 >18 && age2 >18{print("Both are over 18")}if age1 >18 || age2 >18{print("One of them is over 18")}
The ternary operator
letfirstCard1=11letsecondCard1=10print(firstCard1 == secondCard1 ?"Cards are the same":"Cards are different")if firstCard1 == secondCard1 {print("Cards are the same")}else{print("Cards are different")}
Switch statements
switch
fallthrough : 조건에 맞는 case문 이후 모두 수행
letweather="sunny"switch weather {case"rain":print("Bring an umbrella")case"snow":print("Wrap up warm")case"sunny":print("Wear sunscreen")fallthroughdefault:print("Enjoy your day!")}
Range operators
1..<5 ---> 1, 2, 3, 4
1...5 ---> 1, 2, 3, 4, 5
letscore4=85switch score4 {case0..<50:print("You failed badly.")case50..<85:print("You did OK.")default:print("You did great!")}