Android Question If then else structure

wonder

Expert
Licensed User
Longtime User
Is there any difference between the following?

Option 1:
B4X:
Sub Something as Boolean
    If Condition Then
        Return True
    Else
        Return False
    End If
End Sub

Option 2:
B4X:
Sub Something as Boolean
    If Condition Then Return True
    Return False
End Sub
 

MikeH

Well-Known Member
Licensed User
Longtime User
I dont think so but why not just:

B4X:
Return Condition
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
it will compile to the same code because thanks to our fast processor they can do better optimizing which follows/tracks code paths.

it "sees" that both cases end with a return so it will generate example2 for both. I believe they even trash the commands after the if/then as they will never be used/reached.
 
Upvote 0
Top