a.mytype=first mytype
is there such a thing i know i can addlast and addfirst but is there anything like a getfirst or getlast.......
is there such a thing i know i can addlast and addfirst but is there anything like a getfirst or getlast.......
Type TMyType Global list:TList 'list that is global to the type and so can be accessed outside of an instance Field X:Float Field Y:Float Function Create:TMyType(X:Float , Y:Float) If list = Null Then list = New TList Local temp:TMyType = New TMyType temp.x = x temp.y = y list.addLast(temp) Return temp End Function Function getFirst:TMyType() 'since list.first() returns an generic object, we need to cast it as a TMyType to use it properly Return TMyType(list.first()) End Function Function getLast:TMyType() Return TMyType(list.last()) End Function End Type 'make some types TMyType.Create(10.25 , 10.25) TmyType.Create(100.23 , 283.12) TMyType.Create(50 , 10) TmyType.Create(1200.23 , 213.112) TMyType.Create(10 , 350) TmyType.Create(1500.23 , 213.12) TMyType.Create(450 , 10) TmyType.Create(9100.23 , 223.12) Local a:TMyType = TMyType.getFirst() Print a.x For Local i:TMyType = EachIn TMyType.list Print i.x + " : "+i.y Next
a.listor through the type itself:
TMyType.list