I have a scenario where I need to Dim a variable to 2 different classes dependent on an option. When I do this, it gives an error saying that myItem is already declared when option = 2. It should not do this as option 1 is never executed. There is clearly a gap in my understanding. Any suggestions?
B4X:
If option = 1 Then
Dim myItem As Class1
Else if option = 2 Then
Dim myItem As Class2
End If