Download MetaTrader 5

Boolean and = - page 2

To add comments, please log in or register
What is MetaQuotes ID? Find that out from the article!
whroeder1 2014.03.08 13:20  
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
Ex Ovo Omnia 2014.03.08 15:00  

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.
To add comments, please log in or register