• starman
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    edit-2
    9 months ago

    IMO, it would be more readable to just use ifs most of the times. But switch-case fallthrough is indeed, interesting behaviour

    • NotNotMike
      link
      fedilink
      arrow-up
      4
      ·
      9 months ago

      Agreed, multiple if statements are much more readable, in my opinion. I generally think switch statements are always just a little too ugly unless their dead simple.

      Switch expressions, on the other hand, are gorgeous code (as long as you don’t use expression-bodied cases). I am always looking for chances to use switch expressions. So concise

    • canpolatOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      9 months ago

      Because it is about a not-very-well-known feature of the language. Why would it matter that it’s old? I don’t think I have ever seen this in use in production code.

      • Euphorazine@lemmy.world
        link
        fedilink
        arrow-up
        2
        arrow-down
        1
        ·
        9 months ago

        An explanation like that at the start would have been helpful. I was reading the page and just didn’t understand. Was thinking at first it was to raise awareness of an unanswered question. Couldn’t figure it out so I asked.