4 ms·
I noted that ("x" == x) avoids the problem of (x = "x") that others mentioned, but really, any sane compiler will warn you about the second. (GCC does, mxmlc do
by Jach 16y ago
I noted that ("x" == x) avoids the problem of (x = "x") that others mentioned, but really, any sane compiler will warn you about the second. (GCC does, mxmlc does, Python flat out disallows the syntax.) The way to shutup the warning is to say ( (x = "x") ) if you really mean it.
I was more worried that the language in question was C++, so you have to worry about conversion constructors, conversion operators, operator==, etc.
- allenc 16y agoAgreed, although some laxer languages - say, Javascript - will let you do it all the same. Like I said, it's not necessarily a rule to follow, but whenever I come across people who would do things slightly off (from common coding practices anyway) I notice the difference, and if it's something I recognize I put a little mark there in case they're really, really close. I come from a C++ background, so stuff like i++ and ++i really do make a diff.