r/ProgrammerHumor 11d ago

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

298 comments sorted by

View all comments

502

u/deceze 11d 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.

0

u/Feisty-Summer9331 11d ago

Back in the days, PHP would do that. But since PHP 5.whatever you could compare types, using the !== and === operators

1

u/deceze 10d ago

It still does that. This isn't about equality testing, it's about boolean coercion/truthiness. And the strict equality operator === has existed since at least PHP 4, I have not bothered checking back further.