Oliver Simith
Member
Hello, everyone, here's a code snippet that I failed to understand. I don't get why variable mylist still has access to the data of variable lst even if sub t1 is finished. Does this mean that the memory for and data of variable lst isn't released immediately after t1?
B4X:
'-------in main module-------------
sub globals
private mylist as list
...
end sub
sub btton1_click
mylist.initialize
t1
log(mylst.get(0)) 'The purpose of this code is to see if variable lst has been deleted after t1 ends'
end sub
sub t1
Dim lst as list
lst.initialize
lst.add("abcd")
mylst=lst 'variable mylst is a reference to lst'
end t1
'-----the output
abcd