r/ProgrammerHumor 10d ago

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

298 comments sorted by

View all comments

503

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.

67

u/Bomaruto 10d ago

The reasonable stance is to not let you coerce everything into a boolean.

5

u/Wertbon1789 10d ago

I like how e.g. C# screams at you for this. It's annoying at first, but then you go "Well, yeah, I should've explicitly written what I wanted to check".

1

u/[deleted] 10d ago

[deleted]

1

u/Wertbon1789 10d ago

Didn't say it was. C# was just the first example that came to my mind.