S SDFP Studio Member Licensed User May 5, 2021 #1 Hello, good morning, A question I always ask myself to avoid imbricated 'if ... end if'. Is there a constant order in evaluation of boolean conditional and does it stops when it become false ? [CODE lang="b4x" title="Here is kind of what i'd like to be able to write"]If InitVar2(Var1) and Var1 > Var2 then ....[/CODE] If InitVar2(Var1) returns false does it stops evaluation or there is no rule ? Thanks, Francis
Hello, good morning, A question I always ask myself to avoid imbricated 'if ... end if'. Is there a constant order in evaluation of boolean conditional and does it stops when it become false ? [CODE lang="b4x" title="Here is kind of what i'd like to be able to write"]If InitVar2(Var1) and Var1 > Var2 then ....[/CODE] If InitVar2(Var1) returns false does it stops evaluation or there is no rule ? Thanks, Francis
Erel B4X founder Staff member Licensed User Longtime User May 5, 2021 #2 SDFP Studio said: If InitVar2(Var1) returns false does it stops evaluation or there is no rule ? Click to expand... It goes from left to right and stops immediately when the result is determined (short circuit evaluation). This is very important. It allows writing code such as: Code: If i < List.Size And List.Get(i) = "abc" Then Upvote 0
SDFP Studio said: If InitVar2(Var1) returns false does it stops evaluation or there is no rule ? Click to expand... It goes from left to right and stops immediately when the result is determined (short circuit evaluation). This is very important. It allows writing code such as: Code: If i < List.Size And List.Get(i) = "abc" Then
klaus Expert Licensed User Longtime User May 5, 2021 #4 Very interesting ! Added in the B4X Basic language booklet. Upvote 0