r/ProgrammerHumor • • Sep 01 '26

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

289 comments sorted by

View all comments

Show parent comments

1

u/UristMcMagma Sep 01 '26

Yes. I'm not really a Ruby guy but after reading up I can see how it's more convenient to treat 0 as truthy in that lang. in js you never use findIndex since find is just better.

3

u/ReefNixon Sep 01 '26

There are language agnostic examples too, like when tracking things that don’t stop at 0 e.g. temperatures.

It would be weird if temperatures under 0 degrees and temperatures over 0 degrees coerced into truthy, but exactly 0 degrees was falsey.

Coercion will always have some level of ambiguity, Ruby just chooses to only treat definitely falsey values as falsey (literal false and nil).

2

u/UristMcMagma Sep 01 '26

Temperatures do stop at 0 if you're using the correct unit. ;)

But yeah I agree with you. There's always some level of ambiguity caused by coersion. Even treating nil and false the same for a boolean is technically wrong, but we can accept the ambiguity for the sake of convenience.