PLDB
Languages Features Creators Calendar CSV Resources Blog About Donate Add Language
GitHub icon

Switch Statements

< >
var animal = "dog" switch (animal) { case "dog": console.log("yay"); break; case "cat": console.log("oh"); break; }
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++, Deesel, Tick C, cooC, Real-Time Concurrent C, Static Typescript

Languages without Switch Statements include progsbase

Read more about Switch Statements on the web: 1.

HTML of this page generated by Features.ts

hasStructs.html 路 hasSwitch.html 路 hasSymbolTables.html

View source

PLDB - Build the next great programming language Search v2023 Day 157 Docs Acknowledgements Traffic Today Traffic Trends Mirrors GitHub feedback@pldb.com