Android Question Assign List2 = List1 Links Them Forever?

mmieher

Active Member
Licensed User
Longtime User
This surprised me. Is the Universe supposed to behave this way?

Log output:
** Activity (main) Create, isFirst = true **
List1.Size = 3
List2.Size = 3
AFTER List1.Clear then List2.Size = 0
** Activity (main) Resume **

B4X:
Sub Activity_Create(FirstTime As Boolean)
    
    Dim List1 As List
    List1.Initialize
    
    List1.Add("Tom")
    List1.Add("Dick")
    List1.Add("Harry")
    Log("List1.Size = " & List1.Size)
    
    Dim List2 As List = List1
    Log("List2.Size = " & List2.Size)
    
    List1.Clear
    Log("AFTER List1.Clear then List2.Size = " & List2.Size)
    
End Sub
 

Attachments

  • ListTest.zip
    8.1 KB · Views: 179
Top