Android Question [B4X] Boolean evaluation order

SDFP Studio

Member
Licensed User
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 ?

Here is kind of what i'd like to be able to write:
If InitVar2(Var1) and Var1 > Var2 then ....

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
If InitVar2(Var1) returns false does it stops evaluation or there is no rule ?
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:
B4X:
If i < List.Size And List.Get(i) = "abc" Then
 
Upvote 0
Top