DEV Community

Discussion on: What is your pettiest programming-related opinion?

Collapse
 
craigmc08 profile image
Craig McIlwrath

Following that logic, there is no use case for a for loop.

Collapse
 
claudiodavi profile image
Claudio Davi

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.

Thread Thread
 
hyftar profile image
Simon Landry

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.