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.

How to use switch/case (simple pattern matching) in Scala?

I've found myself stuck on a very trivial thing :-] I've got an enum: object Eny extends Enumeration { type Eny = …

scala pattern-matching switch-statement
Is 'switch' faster than 'if'?

Is a switch statement actually faster than an if statement? I ran the code below on Visual Studio 2010's x64 …

c performance switch-statement assembly jump-table
Switch ignore case in java 7

I am doing a POC on Java 7 new features. I have code to use String in switch statement and it …

java switch-statement java-7
How to detect window size and then do something with jquery switch statement

i would like to check for the window size with jquery and based on the different resolutions i would like …

jquery if-statement switch-statement window-resize css
Why can't your switch statement data type be long, Java?

Here's an excerpt from Sun's Java tutorials: A switch works with the byte, short, char, and int primitive data types. …

java switch-statement long-integer language-design
How to do a case with multiple conditions?

In the 1 month experience I've had with any programming language, I've assumed that switch case conditions would accept anything in …

java boolean switch-statement case
Why doesn't String switch statement support a null case?

I am just wondering why the Java 7 switch statement does not support a null case and instead throws NullPointerException? See …

java switch-statement language-design
Switch case statement in coffee script

I have a few different buttons that are calling the same function and I would like to have them wrapped …

if-statement coffeescript switch-statement
Using an NSString in a switch statement

Is it possible to use an NSString in a switch statement? Or is it better to just use if / else …

objective-c nsstring switch-statement
Variable declaration in a C# switch statement

Why is it that in a C# switch statement, for a variable used in multiple cases, you only declare it …

c# switch-statement