var animal = "dog"
switch (animal) {
case "dog": console.log("yay"); break;
case "cat": console.log("oh"); break;
}
- var friends = 10
case friends
when 0
p you have no friends
when 1
p you have a friend
default
p you have #{friends} friends
switch(expression)
{
case 1:
do_something();
case 2:
if (x > 0) nextcase 1; // Jump to 1
nextcase; // Jump to the next case.
default:
foo();
}
Switch[expr,
pattern1, code1,
pattern2, code2,
pattern3, code3
]
(case my-num
(5 (display "Five!"))
(0 (display "Zero!"))
(else (display "Not an option")))
match X {
| Y: outln("X is Y")
| Z: outln("X is Z")
| A | B | C: outln("X is A, B, or C")
|: outln("X is not Y, Z, A, B and C")
}
Languages with Switch Statements include Java, JavaScript, C, C++, PHP, C#, Go, Swift, PowerShell, TypeScript, Objective-C, Dart, Reason, CoffeeScript, Groovy, Pug, ABAP, X10, C3, Wolfram Language, Slope, Jule, Angelscript, Pizza, Apex, Flow9, JS++, Oracle Java, Deesel, Tick C, cooC
Languages without Switch Statements include progsbase
This question asks: Does the language have switch statements or expressions?
Read more about Switch Statements on the web: 1.
HTML of this page generated by Features.ts