Skip to end of banner
Go to start of banner

Switch

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The switch statement is somewhat similar to an if/else statement but can be easier to read when there are many different possible conditions.

Example 1

switch (season) {
    case "Summer":
        print("It's too hot!");
        break;
    case "Winter":
        print("It's too cold!");
        break;
    default:
        print("It's just fine!");
}

  • No labels