Download MetaTrader 5

Boolean and = - page 2

To add comments, please log in or register
whroeder1
16279
whroeder1  
This is why I say: You would never write if( (2+2) == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Especially use readable names for self documenting code: bool isBuy = ...; if(isBuy) OrderSend.
Ex Ovo Omnia
3374
Ex Ovo Omnia  
ydrol:


Many compilers will not warn by default, but will warn when using the most recommended switches for assisting with code quality (eg 'lint' )

So its not a bug, and not a big problem, because MQL4 doesnt mix Booleans and integer types, like C does. its more of a problem with languages that acccept 0 and !0 as false and true.


Neither JAVA compiler warns you in this case. Assignment inside expression is not considered as a good programming technique, but it is part of the language specification. Nevertheless Languages like JAVA have powerful editors, which let you set custom messages coming from their parser.
12
To add comments, please log in or register