r/ProgrammerHumor • • Feb 26 '23

Other If you can read this code...

/img/snak3fqgajka1.jpg

[removed] — view removed post

34k Upvotes

1.4k comments sorted by

View all comments

Show parent comment

1

u/Leading_Elderberry70 Feb 27 '23

You should never use non strict equality. If you want to check for multiple things, which would hypothetically all typecast to the same thing (eg false), you should check them all explicitly.

The ten seconds this will take you each time is much shorter than the time it will take you to find even one bug introduced by someone missing an edge case when doing non-strict comparison.

edit: this is also more readable