Top 1,000 Features Creators Resources Extensions Blog Explorer CSV Download
GitHub icon

Switch Statements

< >
Example from 1 languages: JavaScript
var animal = "dog" switch (animal) { case "dog": console.log("yay"); break; case "cat": console.log("oh"); break; }
Example from 1 languages: C
switch(expression) { case true : break; default : // break; }
Example from 1 languages: Pug
- 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
Example from 1 languages: C3
switch(expression) { case 1: do_something(); case 2: if (x > 0) nextcase 1; // Jump to 1 nextcase; // Jump to the next case. default: foo(); }
Example from 1 languages: Wolfram Language
Switch[expr, pattern1, code1, pattern2, code2, pattern3, code3 ]
Example from 1 languages: Slope
(case my-num (5 (display "Five!")) (0 (display "Zero!")) (else (display "Not an option")))
Example from 1 languages: Jule
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 JavaScript, C, Java, PHP, Go, C#, PowerShell, Swift, CoffeeScript, Objective-C, Dart, Reason, Groovy, Pug, ABAP, C3, Wolfram Language, Slope, Flow9, X10, Angelscript, Apex, Jule, JS++


Languages without Switch Statements include progsbase


View all concepts with or missing a hasSwitch measurement


Read more about Switch Statements on the web: 1.

View source

- Build the next great programming language About Acknowledgements Part of the World Wide Scroll