Bug? List initialization

LucaMs

Expert
Licensed User
Longtime User
If you are using Initialize2, then the Clear method does not work.

B4X:
Dim lst As List
lst.Initialize2(Array As String("One", "Two", "Three"))
'lst.Initialize
'lst.Add("One")
'lst.Add("Two")
'lst.Add("Three")
lst.Clear


java.lang.UnsupportedOperationException
 

eps

Expert
Licensed User
Longtime User
http://www.b4x.com/android/forum/threads/bug-with-list-initialize2.31006/

"
Initializes a list with the given values. This method should be used to convert arrays to lists.
Note that if you pass a list to this method then both objects will share the same list,
and if you pass an array the list will be of a fixed size. Meaning that you cannot later add or remove items.
"
 

LucaMs

Expert
Licensed User
Longtime User


I was trying to pass list as a parameter to a function and change the content of it, inside the function.

But no matter, I initialize it with the normal method
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…