From 9b3ed18f758bd45830b8759c1e874ac68b0ae2bd Mon Sep 17 00:00:00 2001 From: JezuzLizard Date: Mon, 18 May 2020 23:55:29 -0700 Subject: [PATCH] updated info.md with more information on the compiler --- info.md | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/info.md b/info.md index b9b23dd..ed6768d 100644 --- a/info.md +++ b/info.md @@ -1,5 +1,45 @@ # Limitations of the compiler -You cannot use nested foreaches it will cause an infinite loop +**You cannot use nested foreaches it will cause an infinite loop** -You cannot use continues in foreaches or for loops it will cause an infinite loop \ No newline at end of file +**You cannot use continues in foreaches or for loops it will cause an infinite loop** + +**You should always use parenthesis when comparing values using conditions while using operators** + +```( 0 - 1 ) < 1``` is NOT the same as ```0 - 1 < 1``` the compiler will compile it as ```0 - ( 1 < 1 )``` + +```( 0 - 1 ) < 1``` will return 1 because 1 is greater than -1 + +```0 - 1 < 1 ``` will return 0 because it will compare the values then subtract + +ALWAYS SPECIFY PARENTHESIS WHEN OPERATORS ARE INVOLVED + +**You cannot use more than 2 conditions in an IF statement connected by OR operators enclosed in parenthesis** EXAMPLE: +``` +if ( ( a || b || c ) && d ) +``` +WILL NOT COMPILE + +However, you can rewrite this as: +``` +if ( ( a || b ) && d || c && d ) +OR +if ( a && d || b && d || c && d ) +``` + +**You cannot use OR operators in an IF statement in parenthesis if the string of conditions would not be on the leftmost side of the if statement and the number of conditions on the rightmost side is not at least 2.** +EXAMPLE: +``` +if ( a && ( b || c ) ) +WILL NOT COMPILE +``` +However, +``` +if ( ( b || c ) && a ) +WILL COMPILE +``` +In the case of +``` +if ( ( a || b ) && ( c || d ) ) +WILL COMPILE +```