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.

C# Switch with String.IsNullOrEmpty

Is it possible to have a switch in C# which checks if the value is null or empty not "" but …

c# string switch-statement semantics
What is the runtime complexity of a switch statement?

I'd like to know what the worst-case runtime complexity of a switch statement is, assuming you have n cases. I …

algorithm programming-languages switch-statement big-o
'break' statement when using curly braces in switch-case

I use curly braces with all of my switch case statements in C/Objective-C/C++ I had not, until a …

c coding-style curly-braces switch-statement
switch-case statement for STRINGS in Python

I need to do something similar to the CASE WHEN .. OR .. THEN from SQL in python for STRINGS. For example, …

python dictionary switch-statement case type-synonyms
What is the difference between switch and select in Go?

Is there any difference between switch and select in Go, apart from the fact that one takes an argument and …

go switch-statement goroutine
Bitmask switch statement

I have this code in a section of my project: enum myEnum { invalid = -1, val1 = 1, val2 = 2, val3 = 4 }; int bitmask = val1 | …

c++ switch-statement bitwise-operators bitmask bit-masks
How to detect a user's language through their IP Address

I have developed a website www.tenxian.com. It has three language versions, English, Japanese and Chinese. How can I …

php localization switch-statement ip-geolocation
Reduce Cyclomatic Complexity of Switch Statement - Sonar

I want to reduce cyclomatic complexity of my switch case my code is : public String getCalenderName() { switch (type) { case COUNTRY: …

java switch-statement sonarqube cyclomatic-complexity
Why "final static int" can be used as a switch's case constant but not "final static <your enum>"

Why is this int switch valid: public class Foo { private final static int ONE = 1; private final static int TWO = 2; public …

java enums constants case switch-statement
how to combine switch and if else statements

I'm taking an online java class and the teacher has asked for the following: Write a menu program that ask …

java switch-statement flow-control