B4J Question [BANano] Evaluate boolean without variable

angel_

Well-Known Member
Licensed User
Longtime User
When a boolean is evaluated without using a variable it seems to not correctly interpret the result:

B4X:
Sub MenuList_Click (returnName As String)
    Dim Number1 As Double = 3
    Dim Number2 As Double = 5
    Dim Operation As String = "sum"
    
    Log(Operation = "sum")            'return sum
    Log(Operation = "subtract")        'return subtract
    Log(MyFunction(Number1, Number2, Operation = "sum"))        'return 8
    Log(MyFunction(Number1, Number2, Operation = "subtract"))    'return 8
End Sub

Sub MyFunction(a As Double, b As Double, Operation As Boolean) As Double
    Dim Result As Double
    
    If Operation Then
        Result = a + b
    Else
        Result = a - b
    End If
    
    Return Result
End Sub

I guess this error is related to this other:
 
Top