Skip to end of banner
Go to start of banner

Switch Case

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 »

This is probably the second most common statement to use. It is helpful when working
with fields that contain multiple values or when working with multiple issues
(just for an example).

Example 1 - Finite number of loops

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

Example 2 - Looping through an array

Error rendering macro 'excerpt-include' : No link could be created for 'Switch Case Example 2'.

Example 3 - Looping through an array with index

Error rendering macro 'excerpt-include' : No link could be created for 'Switch Case Example 3'.

  • No labels