B4J Question Map Bug or WAI?

cyiwin

Active Member
Licensed User
Longtime User
I ran into a little problem transferring and clearing Maps. Maybe I'm doing it wrong, here is the code:

B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim Map_A, Map_B As Map
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
   
    Map_A.Initialize
    Map_B.Initialize
   
    For i = 0 To 99
        Map_A.Put(i, Rnd(0,1000))
    Next
   
    Map_B = Map_A               'Works
    Log(Map_B)
    Map_A.Clear                 'Why does this clear Map_A and Map_B ?
    Log(Map_B)
End Sub


Why would both maps clear? Is there a better way to write Map_B = Map_A?
 
Top