Swift: Switch and default case

This entry is part 27 of 41 in the series Swift

As in any other programming languages, the default case will be called when none of the cases are matched.

var num = 100
switch num {
case 10:
    print("=10")
case 20:
    print("=20")
case 30:
    print("=30")
case 40:
    print("=40")
default:
    print("None of the above")
}

swift

Series Navigation<< Swift: Swapping of 2 variables
Swift: Enum type >>

Leave a comment

Leave a Reply