DEV Community

Discussion on: ✔||🤢 Commit or Vomit | Switch(true)

Collapse
 
indoor_keith profile image
Keith Charles

While the code is valid, I think the real issue here is just the amount of conditions you're trying to parse through. Using switch (true) feels more like a band-aid than a solution I would accept say in a PR.

I'm a fan for using switches when we're actually comparing the value in switch(value). Someone mentioned checking for a match in the zodiac. Perfect use case for a switch statement.

When you have to resort to a hacky solution, chances are the problem lies more with the code leading up to this decision than the decision itself.

Collapse
 
jmdejager profile image
🐤🥇 Jasper de Jager

Totally agree! It's a code smell.