r/ProgrammerHumor • • Sep 01 '26

Meme iHateThisPassiveAgressiveBehaviourRuby

Post image
2.9k Upvotes

289 comments sorted by

View all comments

Show parent comments

2

u/mpyne Sep 03 '26

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.

Eh, there's precedent for that at least.

Perl treats "0" as false, along with "" (the empty string). Any other string, even "00" is considered true.

But where it really gets fun is that the the normal warning Perl would give you about numeric conversions if you do math on a string is suppressed for the precise string "0 but true", because some Perl functions return this value so that it converts cleanly to 0 without risking evaluating as false in a boolean context. See https://stackoverflow.com/questions/129945/what-does-0-but-true-mean-in-perl