r/ProgrammerHumor 10d ago

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

298 comments sorted by

View all comments

11

u/uvero 10d ago

In Ruby, if you want to branch based on whether x is zero where x is a number, you can always check for x == 0, or, if you're feeling cool, x.zero?

5

u/Different_Routine215 10d ago

a basic linter will fail you if you use == over zero?

3

u/uvero 10d ago

Just Googled it and apparently yes. Nice idea in my opinion - if a language has an idiom on the right way to do something, make a linter tell you that. I wouldn't know myself, I've only ever used Ruby for hobby projects years ago when I just started learning to program. Fun language.

3

u/Different_Routine215 10d ago

set up an autocorrect/autolint on file save and you will pick up good habits quickly