List to array

Ferret3D

Member
Joined
Aug 13, 2017
I have a list filled with a custom class.
How do i create a new array and fill it with ListToArray()?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
How about this?

Code:
Function Main:Int()
    Print ("Creating List")
    Local myList:= New IntList()
    myList.AddLast(1)
    myList.AddLast(2)
    myList.AddLast(3)
    For Local listNode = Eachin myList
        Print(listNode)
    Next
    Print ("Creating array from List")
    Local myArray[] = myList.ToArray()
   
    Print ("Array length="+myArray.Length())
    For Local index:Int = 1 To myArray.Length()
        Print(myArray[index-1])
    Next
    Print ("finish")
   
    Return 0
End
 
Top Bottom