Switch Statement in Swift

This post was originally posted at https://agrawalsuneet.github.io/blogs/switch-statement-in-swift/ and reposted on Medium on 12th April 2022.
switch (expression)  {
case value1:
// statements
case value2:
// statements
...
...

default:
// statements
}
let dayOfWeek = 2switch dayOfWeek {	    
case 1:
print("Monday")

case 2:
print("Tuesday")

case 3:
print("Wednesday")

case 4:
print("Thursday")

case 5:
print("Friday")

case 6:
print("Saturday")
case 7:
print("Sunday")

default:
print("Invalid day")
}
//this will print
//Monday

Things to notice here

Please continue reading at https://agrawalsuneet.github.io/blogs/switch-statement-in-swift/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store