I an just trying to understand why this code does not return the List content using the following code? (I can however get the new List content by declaring List1 in Sub Global)
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim List1 As List
List1.Initialize
List1.AddAll(Array As Int(1, 2, 3, 4, 5, 6, 7, 8, 9))
ShuffleList(List1)
For i = 0 To List1.Size - 1
Log(List1.Get(i))
Next
End Sub
Sub ShuffleList(aList As List) As List
Dim j As Int
Dim NewList As List
NewList.Initialize
For i = aList.Size - 1 To 0 Step -1
j = Rnd(0, i + 1)
Log("i: " & i & ", aList.Get(j): " & aList.Get(j))
NewList.Add(aList.Get(j))
aList.RemoveAt(j)
Next
Return NewList
End Sub