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.

Expression inside switch case statement

I'm trying to create a switch statement but I can't seem to be able to use an expression that gets …

javascript switch-statement case
Which is Faster and better, Switch Case or if else if?

Which is the better and fastest methods : if or switch ? if(x==1){ echo "hi"; } else if (x==2){ echo "bye"; } switch(…

php performance if-statement switch-statement
Status "S" in Subversion

At some point all files in my working copy got marked with "S" symbol as shown below: $ svn st M …

svn switch-statement status
Why do we need break after case statements?

Why doesn't the compiler automatically put break statements after each code block in the switch? Is it for historical reasons? …

java switch-statement case language-design break
SWITCH with LIKE inside SELECT query in MySQL

I have this Tags table CREATE TABLE IF NOT EXISTS `Tags` ( `id_tag` int(10) unsigned NOT NULL auto_increment, `tag` …

sql mysql case switch-statement sql-like
Switch over type in java

Before I start, I know there are a bunch of answers to this question that suggest alternate approaches. I'm looking …

java types enums switch-statement instanceof
If vs. Switch Speed

Switch statements are typically faster than equivalent if-else-if statements (as e.g. descibed in this article) due to compiler optimizations. …

c# performance switch-statement if-statement
php switch case statement to handle ranges

I'm parsing some text and calculating the weight based on some rules. All the characters have the same weight. This …

php range switch-statement
Select Case on an object's type in VB.NET

I'm not sure if this valid C#, but hopefully you get the idea. :) switch (msg.GetType()) { case ClassA: // blah case …

vb.net switch-statement select-case
Lesser than or greater than in Swift switch statement

I am familiar with switch statements in Swift, but wondering how to replace this piece of code with a switch: …

swift switch-statement