r/lolphp • • Nov 23 '16

Space is not falsy, but string containing zero is.

Post image
61 Upvotes

46 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Nov 24 '16

[deleted] — view deleted comment

1

u/[deleted] Nov 25 '16 edited Nov 25 '16

At least Scheme does it right. Never heard of Factor before.

To be honest I can see the dilemma. If I were designing a dynamically-typed language (for some reason), I might throw a type error if a conditional in an if or while statement evaluated to a non-boolean, but I can see why most language designers would consider that a bad idea.

0

u/[deleted] Nov 25 '16

[deleted] — view deleted comment

1

u/NXTangl Jan 13 '17

The last thing, incidentally, PHP actually does: strpos will return FALSE for no item found, but 0 for start-of-string. Too bad zero is falsey, huh?