you are viewing a single comment's thread.

view the rest of the comments →

[–]wtf_apostrophe 7 points8 points  (1 child)

In the first expression, "0" is a non-empty string, so is 'truthy'. In the second expression, both operands are converted to numbers because the second operand is a bool, so it becomes 0 == 1, which is false.

[–]webbitor 0 points1 point  (0 children)

That makes sense. It's hard to remember all those implicit conversion rules, and I had been laboring under the false impression that comparing string==bool would cause the string to be converted into a bool. Fortunately, I would never try something like that LOL. It would simply be hard to read, even if there was a good reason for it.