I've been using the SELECT TRUE construct to simplify some conditional logic, like this:
I had been assuming that if a case returns TRUE (e.g. isRoyalFlush), then the SELECT statement does that block (e.g. Return 10), then exits the SELECT statement (i.e. just like an IF statement would skip the ELSE logic).
However, it seems that SELECT tests every case, even if it gets a match early on. Is this true, and if so, is this the proper behaviour? If I have several cases that match, would all of those blocks get executed? Even if I use a RETURN as above?
(In the example above, a royal flush is also a straight flush. Ideally, I only want 1 case returned.)
If so, that's an important difference from using the alternative IF/ELSE/ELSE/etc construct.
B4X:
sub evaluateHand as short
Select True
Case isRoyalFlush
Return 10
Case isQuads
Return 10
Case isStraightFlush
Return 10
Case isFullHouse
Return 9
End Select
end sub
I had been assuming that if a case returns TRUE (e.g. isRoyalFlush), then the SELECT statement does that block (e.g. Return 10), then exits the SELECT statement (i.e. just like an IF statement would skip the ELSE logic).
However, it seems that SELECT tests every case, even if it gets a match early on. Is this true, and if so, is this the proper behaviour? If I have several cases that match, would all of those blocks get executed? Even if I use a RETURN as above?
(In the example above, a royal flush is also a straight flush. Ideally, I only want 1 case returned.)
If so, that's an important difference from using the alternative IF/ELSE/ELSE/etc construct.