• herr@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    Imagine getting hung up on something as trivial as a switch statement. Which is more poignant, I ask you?

    switch(var){
       case 1: 
          <code>;
          break;
       case 2: 
          <code>;
          break;
       case 3: 
          <code>;
          break;
       default:
          <code>
    }
    

    or

    if var == 1:
       <code>
    elif var == 2:
       <code>
    elif var== 3:
       <code>
    else:
        <code>
    

    The performance difference is absolutely negligible, but now you’ve introduced a bunch of unnecessary indentation (for no benefit) that’s gonna get hard to read should you even add a little bit of additional logic, and a footgun with all the break; s.

    And then in JS the syntax for the case-blocks isn’t even consistent with the rest of the language.</code></code></code></code></code></code></code></code>