But really, can you give me a legit use case?
I cannot think of one single thing that is not a bad pattern switch(true) or could not be solved with an if and early return.
Switch cases are syntactic sugar for writing repetitive if and else if statements, not a language feature. Just like the for loop, you could write a while loop that does exactly the same thing.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
But really, can you give me a legit use case?
I cannot think of one single thing that is not a bad pattern
switch(true)
or could not be solved with an if and early return.Switch cases are syntactic sugar for writing repetitive
if
andelse if
statements, not a language feature. Just like the for loop, you could write a while loop that does exactly the same thing.