News for hackers. Stuff that matters.
Re:Using the switch(true) pattern in JavaScript by TeMPOraL on Monday April 12, 2021 @06:11PM (#26785810)
The only problem here is that you have to do this in the first place. This problem has been solved some 60 years ago with Lisp and `cond` construct, which is even older than `if/else if/else`! Alas, our industry likes to forget history.

That said, this isn't some kind of high-level hackery. If it's cleaner than if/else if chain, you should use it.

Programming is a profession. A professional is expected to learn and grow. The right answer to seeing a code construct one doesn't understand isn't throwing hands up in the air, but spending the few minutes necessary to figure out what it does.

There are no comments on this comment yet.