bool SampleFunction() { return(true); } // The "!" operator is used to negate the value of a function. If a function returns "true", it will make it "false" and vice-versa. // Example if(SampleFunction() == true) { Alert("TRUE"); } else { Alert("FALSE"); } // Alerts "TRUE". if(!SampleFunction() == true) { Alert("TRUE"); } else { Alert("FALSE"); } // Alerts "False".
KeepMarcos: Why some programmers put the "!" before a function ??
| 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). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled. Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence. |
WHRoeder:
Since the OP did not know what the "!" meant, I used the example above to make the point extra clear and obvious, however, your clarification is correct. Hopefully the OP now understands what the "!" operator does and is not further confused by your clarification which does not answer OP's question. Cheers
KeepMarcos: Why some programmers put the "!" before a function ?? | 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). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled. Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence. |

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello people!!
Why some programmers put the "!" before a function ??
example:
!isPositionOpen() and isPositionOpen()
What do the different "!" ??
thanks for help! =]