If I have a statement like this:
if(Bool1() || Bool2()){...}
where Bool1 returns True and Bool2 produces an error; does this if-statement produce an error or does Bool2() get ignored. In other words, are if-statements eagerly evaluated in the MQL4 Language?
I understand that if the first condition is true, the 2nd will not be checked as there is no need to.
Why would Bool2 produce an error? A bool function should only return true or false.
I understand that if the first condition is true, the 2nd will not be checked as there is no need to.
Why would Bool2 produce an error? A bool function should only return true or false.
Thanks, and to answer your question, Bool2 can produce an error just like any other function. Example:
bool Bool2(){
int x = 1/0;
int y = 2;
return x == y;
}
static int array[];
int arr_size = ArraySize(array);
if( (arr_size > NULL)
&& (Array[arr_size - 1] != NULL) )
{ ... }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
If I have a statement like this:
if(Bool1() || Bool2()){...}
where Bool1 returns True and Bool2 produces an error; does this if-statement produce an error or does Bool2() get ignored. In other words, are if-statements eagerly evaluated in the MQL4 Language?