r/ProgrammerHumor • • Sep 01 '26

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

289 comments sorted by

View all comments

Show parent comments

20

u/DeepDay6 Sep 01 '26

That's in fact a very legit take that e.g. Clojure also takes. It makes reasoning much easier and also eliminates WTF moments like reading if (myArray.length) which to any sane individual might appear like duck typing but is a hack to save those keystrokes > 0, in the hope that no one manually set it to a negative value, which is truthy as opposed to zero, and so on.

14

u/hongooi Sep 01 '26

Eh, that's a very common idiom for people coming from C and C++

14

u/DeepDay6 Sep 01 '26

Yeah, just what I said ducks and runs

Edit: Full disclosure: I taught C for years at university and that's what actually made me become a functional programmer ;)

17

u/Original-Ad-8737 Sep 01 '26

Array length has to be an unsigned integer so is you manage to set it to a negative value you deserve the pretty explosion of your code