B4J Question Array of object

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi!

I have a technical question.

Having this code will always log -1

B4X:
        Dim rad As RadioButton = Sender
        Dim l As List = Array as radiobutton (radEsc0,radEsc1,radEsc2,radEsc3,radEsc4,radEsc5,radEsc6)
        Log(l.IndexOf(rad))

having this code will log the correct index:

B4X:
        Dim rad As RadioButton = Sender
        Dim l As List = Array(radEsc0,radEsc1,radEsc2,radEsc3,radEsc4,radEsc5,radEsc6)
        Log(l.IndexOf(rad))

The question is why???
and the second question would be, should i always use the second option?
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Insert this into both your code snippets for an important clue:
B4X:
Log(GetType(rad) & " " & GetType(l.Get(0)))
 
Upvote 0
Top