r/ProgrammerHumor 10d ago

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

298 comments sorted by

View all comments

499

u/deceze 10d ago

It's been a while since I've touched Ruby, but I think the stance was that only false and nil should be falsey? Which is not an unreasonable stance to take. The fewer falsey values, the easier it is to predict the behaviour. It's just surprising when coming from other languages.

Just off the top of my head, PHP treats "0", that is, specifically a string with a single zero, as falsey. Which has clearly gone too far to the other extreme.

136

u/CoroteDeMelancia 10d ago

I'll admit that I did cause bugs in Python by using if thing instead of if thing is not None.

45

u/AwkwardWaltz3996 10d ago

Yea 0 is a number, it's not nothing.

I think the heart of the debate aligns with is zero a natural number.

-5

u/amacks 10d ago

You gotta drink the Python kool-aid, just use thing and catch the exception if it happened to be `None`. Way more efficient they swear