Questions Concepts
GitHub icon

Switch Statements

Switch Statements - language feature

< >
Example from JavaScript, TypeScript:
var animal = "dog" switch (animal) { case "dog": console.log("yay"); break; case "cat": console.log("oh"); break; }
Example from C, C++, Tick C:
switch(expression) { case true : break; default : // break; }
Example from 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 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 Wolfram Language:
Switch[expr, pattern1, code1, pattern2, code2, pattern3, code3 ]
Example from Slope:
(case my-num (5 (display "Five!")) (0 (display "Zero!")) (else (display "Not an option")))
Example from 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 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

View source

- Build the next great programming language Search Add Language Features Creators Resources About Blog Acknowledgements Queries Stats Sponsor Traffic Traffic Today Day 305 Logout