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: Python match x: case 0: print("zero") case 1: print("one") case _: print(f"other: {x}") ``` ```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: Chapel select ``` ```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, Python, Java, PHP, Go, C#, PowerShell, Swift, CoffeeScript, Objective-C, Dart, Reason, Pug, Chapel, Groovy, C3, ABAP, Wa-lang, Wolfram Language, Slope, Flow9, X10, Jule, Angelscript, Apex, JS++ * Languages *without* Switch Statements include Lil, progsbase * View all concepts with or missing a *hasSwitch* measurement http://pldb.info/../lists/explorer.html#columns=rank~id~appeared~tags~creators~hasSwitch&searchBuilder=%7B%22criteria%22%3A%5B%7B%22condition%22%3A%22null%22%2C%22data%22%3A%22hasSwitch%22%2C%22origData%22%3A%22hasSwitch%22%2C%22type%22%3A%22num%22%2C%22value%22%3A%5B%5D%7D%5D%2C%22logic%22%3A%22AND%22%7D missing http://pldb.info/../lists/explorer.html#columns=rank~id~appeared~tags~creators~hasSwitch&searchBuilder=%7B%22criteria%22%3A%5B%7B%22condition%22%3A%22!null%22%2C%22data%22%3A%22hasSwitch%22%2C%22origData%22%3A%22hasSwitch%22%2C%22type%22%3A%22num%22%2C%22value%22%3A%5B%5D%7D%5D%2C%22logic%22%3A%22AND%22%7D with * Read more about Switch Statements on the web: 1. https://en.wikipedia.org/wiki/Switch_statement 1. Built with Scroll v178.2.3