Top "Switch-statement" questions

In computer programming, a switch, case, select or inspect statement is a type of selection control mechanism used to invoke specific blocks of code based on variable contents.

What's the PowerShell syntax for multiple values in a switch statement?

I basically want to do this: switch($someString.ToLower()) { "y", "yes" { "You entered Yes." } default { "You entered No." } }

powershell switch-statement
Switch in Laravel 5 - Blade

How can I use switch in blade templates? When I used: @switch($login_error) @case(1) `E-mail` input is empty! @break @…

php laravel switch-statement laravel-5 blade
How to break out of a loop from inside a switch?

I'm writing some code that looks like this: while(true) { switch(msg->state) { case MSGTYPE: // ... break; // ... more stuff ... case …

c++ loops syntax switch-statement break
What is the relative performance difference of if/else versus switch statement in Java?

Worrying about my web application's performances, I am wondering which of "if/else" or switch statement is better regarding performance?

java performance switch-statement if-statement
Advantage of switch over if-else statement

What's the best practice for using a switch statement vs using an if statement for 30 unsigned enumerations where about 10 have …

c++ if-statement optimization switch-statement
Using continue in a switch statement

I want to jump from the middle of a switch statement, to the loop statement in the following code: while (…

c++ c switch-statement break continue
C# switch statement limitations - why?

When writing a switch statement, there appears to be two limitations on what you can switch on in case statements. …

c# switch-statement
Switch case: can I use a range instead of a one number

I want to use switch, but I have many cases, is there any shortcut? So far the only solution I …

c# switch-statement
Switch/toggle div (jQuery)

I wish to accomplish a fairly simple task (I hope!) I got two div tags and one anchor tags, like …

jquery html switch-statement toggle
Regarding Java switch statements - using return and omitting breaks in each case

Given this method, does this represent some egregious stylistic or semantic faux pas: private double translateSlider(int sliderVal) { switch (sliderVal) { …

java return switch-statement case break