About 50 results
Open links in new tab
  1. What are switch expressions and how are they different from switch ...

    Jan 10, 2021 · As part of Java SE 12, switch expressions were introduced and since Java SE 14, they have been standardized. How are they different from switch statements?

  2. Replacements for switch statement in Python? - Stack Overflow

    Sep 13, 2008 · I want to write a function in Python that returns different fixed values based on the value of an input index. In other languages I would use a switch or case statement, but Python does not …

  3. 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. It also works with enumerated types (discussed in Classes and Inheritance) an...

  4. Switch statement for multiple cases in JavaScript

    35 In Javascript to assign multiple cases in a switch, we have to define different case without break inbetween like given below:

  5. What is the Python equivalent for a case/switch statement?

    Jul 14, 2012 · What is the Python equivalent for a case/switch statement? [duplicate] Asked 13 years, 6 months ago Modified 7 months ago Viewed 2.8m times

  6. Switch statement: must default be the last case? - Stack Overflow

    The case statements and the default statement can occur in any order in the switch statement. The default clause is an optional clause that is matched if none of the constants in the case statements …

  7. Why can't variables be declared in a switch statement?

    Sep 18, 2008 · It appears that anonymous objects can be declared or created in a switch case statement for the reason that they cannot be referenced and as such cannot fall through to the next …

  8. Why can't the switch statement be applied to strings?

    An optimized version of a switch statement that can work with strings is definitely possible. The fact that they can't reuse the same code path they use for primitive types doesn't mean that they can't make …

  9. When to use If-else if-else over switch statements and vice versa

    Aug 13, 2017 · Why you would want to use a switch block over a series of if statements? switch statements seem to do the same thing but take longer to type.

  10. How to write switch statement with "or" logic? - Stack Overflow

    Mar 10, 2013 · Below, I have created a simple switch statement that works fine. I was wondering how I could change this code so it is switch(c), then case 1, case 2, case 3, default. Example: if char is 'w' || ...