News for hackers. Stuff that matters.
Re:Ruby's Switch Statement Is More Flexible Than You Thought by cout on Wednesday April 26, 2023 @11:22AM (#35715147)
Ruby does not have a switch statement; it has a case expression (which can be used in a statement).
Re:Ruby's Switch Statement Is More Flexible Than You Thought by ape4 on Wednesday April 26, 2023 @11:31AM (#35715329)
That naming is rather maddening.
Re:Ruby's Switch Statement Is More Flexible Than You Thought by layer8 on Wednesday April 26, 2023 @12:20PM (#35716177)
It’s the same in SQL and Ada. “Case” is an abbreviation for “case distinction” here.

“Switch” was never intuitive to me, because nothing gets switched.

Re:Ruby's Switch Statement Is More Flexible Than You Thought by mekster on Wednesday April 26, 2023 @07:56PM (#35721532)
"Switch" to this statement in "case" of this expression, seems quite easy to grasp.
Re:Ruby's Switch Statement Is More Flexible Than You Thought by calo_star on Wednesday April 26, 2023 @12:52PM (#35716687)
It's the same in Haskell, Erlang and Elixir.