Yeah, but since I came from BASIC where that would result in an syntax error and the comparative having only a single equals sign is the valid syntax, that threw me for a loop.
I would just generally stay away from anything that wasn’t typed language. I’ve been there and don’t like it. But when I have to I have enough experience to see where the pitfalls are.
I deal with a legacy system where one of the previous programmers really liked text string booleans. My isTrue tests for true, "true", 1, "1", "yes", and "on".
Regardless of type, if you compare to a constant, you can write if(constant==variable); this will produce an error if you only write one equals sign by mistake. Unfortunately it doesn't look quite as nice (but fortunately most compilers warn about if(a=b) anyway)
When the language you are using is not typed and your function can return false, true, "banana for scale" or digit. This is why I always write "true === isMoronLanguage()" to avoid this type of error
View all comments
1.5k
u/DaniilBSD Mar 15 '22
If you do “bool == true” you deserve every “bool = true”