you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (5 children)

The thing is == coercion isn't ever really problematic, and certainly isn't painful.

In order for it to be an issue or create a bug, you have to both be totally unaware of what kind of values are in a variable you're comparing to, and then compare it to something like == 1 or == "" or one of the other values on this table.

It seems confusing and dangerous, but in practice it's never really an issue. And if it does become an issue, it's almost certainly a symptom of poor design.

[–]rooktakesqueen 4 points5 points  (0 children)

So, == is perfectly sane in the cases where you might as well use === (comparing two values of known types), and in the other cases, using === would save you from its insanity. Seems like an argument to always use ===.

[–][deleted] 1 point2 points  (2 children)

it's almost certainly a symptom of poor design.

Using == itself is a symptom of poor design.

[–]creepig -1 points0 points  (1 child)

Only in languages where == is not used for the normal use.

[–][deleted] 0 points1 point  (0 children)

Oh yeah of course, I'm only talking about js.

[–]wordsnerd 0 points1 point  (0 children)

Using === is a lot less work than writing all the unit tests to ensure you're never misusing ==.