Adding standard datatypes to a TList

BlitzMax Forums/BlitzMax Beginners Area/Adding standard datatypes to a TList

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The only way you can store a group of Ints/Floats/Doubles directly is by using an array - lists can only store Objects, and as the primitive types listed aren't Objects, you can't store them in a list (atleast, not directly).

However, you can store them if you convert them to an Object before adding them to the list, and the quickest way to do this is to convert them into strings (which are objects) just before adding them. For example,

Local tmpFloat:Float, myList:TList = New TList
myList.AddLast String(tmpFloat)
If myList.Contains(String(tmpFloat)) Then Print "Found!" Else Print "Error!"
Obviously, when looping through the items, you'll have to cast them back to Floats again (if you want to use them in calculations).