Don't use zero in constants if you value your sanity
This has happened to me enough times now that I should know better.
I have a constant:
I use this constant to check the status of something:
The if
statement will never actually work, because in the statuses
constant OK
is 0
, which is falsy, meaning that the if (currentStatus
part won’t be true.
It’s very easy to solve this, just use strings or positive values:
Me, after this has happened for the third time, necessitating this post: