r/ProgrammerHumor 20h ago

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.5k Upvotes

268 comments sorted by

View all comments

10

u/uvero 19h 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?

3

u/Different_Routine215 17h ago

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

5

u/uvero 17h 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 16h ago

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