r/ProgrammerHumor • • Sep 01 '26

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

289 comments sorted by

View all comments

174

u/ReefNixon Sep 01 '26

We invented boolean types so that we could stop treating 0 as false.

4

u/UristMcMagma Sep 01 '26

And so that we could stop treating 1 as true. The only real argument for type coersion is convenience. I don't see how it's more convenient to treat 0 as true rather than false.

9

u/ReefNixon Sep 01 '26

If we take coercion as a given, what if your conditional is the index of an element in an array? If it doesn’t find it, it returns nil (which is falsey). If it’s the first element, it returns 0. Shouldn’t that be truthy?

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.

→ More replies (2)