Can someone please tell me why in the following the If...Else...EndIF works OK, but the Inline IIf fails or at least seems to produce an array rather than a list:
Changing the string arrays to Int arrays still fails in a similar way.
Many thanks.
B4X:
Private Sub Button1_Click
Private b As Boolean
'This works OK.
If b Then
Dim colours As List = Array As String(xui.Color_Black, xui.Color_Black)
Else
Dim colours As List = Array As String(xui.Color_Blue, xui.Color_Blue)
End If
Log(colours) '(ArrayList) [-16776961, -16776961]
' But here colours seems to end up as an array rather than a list, or sometimes I get
' an exception: java.lang.ClassCastException:
' class [Ljava.lang.String; cannot be cast to class java.util.List ([Ljava.lang.String; and java.util.List are in module java.base of loader 'bootstrap')
Dim colours As List = IIf(b, Array As String(xui.Color_Black, xui.Color_Black), Array As String(xui.Color_Blue, xui.Color_Blue))
Log(colours) '(String[]) [Ljava.lang.String;@3fb4917d
End Sub
Changing the string arrays to Int arrays still fails in a similar way.
Many thanks.