Hacker News new | ask | show | jobs
by jpcrs 1254 days ago
I don't know why so many people are saying that this is bad code.

Besides the redundant checks, it's really simple, so simple that an intern, maybe even someone who doesn't code, can understand and update it.

It's performant, most compilers will cache the strings.

People trying to justify more complex one-liners with "what if you change the symbol, or just show 5 characters" etc. These scenarios wouldn't take more than 5 minutes to adapt this code, and anyone could do it.

For me, this code with a good set of tests doesn't get much better.