July 2018
Beginner
552 pages
13h 18m
English
The switch statement is also a conditional statement, and can handle many types of conditions. You should make use of it when you want to check multiple conditions at once. The basic syntax looks as follows:
Switch (<test-value>) { <condition> {<action>} <condition> {<action>} }
It starts with the switch keyword, followed by the value that you want to test and validate the conditions on. Then, the curly braces follow, with a variable number of conditions. Each condition will handle one scriptblock. This scriptblock can be a single line or a complete, multilined script:
# Simple exampleswitch (42){ 1 {"It is one."} 2 {"It is two."} 42 {"It is the answer of everything."}}# "It is the answer of everything."
You can add various numbers ...
Read now
Unlock full access