how to get first type in a list

BlitzMax Forums/BlitzMax Beginners Area/how to get first type in a list

slenkar(Posted 2008) [#1]
Hi,
how do you get the first type in a list?


AltanilConard(Posted 2008) [#2]
yourlist.first() returns the first object in the list.


slenkar(Posted 2008) [#3]
thanks


degac(Posted 2008) [#4]
Global list:TList = New TList

list.addlast "First"
list.addlast "Second"
list.addlast "Third"


Local first_object$ = String(list.First() )

Print "First item: "+first_object

Edit: tooooo...late!


slenkar(Posted 2008) [#5]
I found this on the forums and its the only thing that works:

w:wizard = wizard(wizard.list.first())

when you put brackets after the type name what does it mean in blitzmax?

like this:
wizard(wizard.list.first())

I have never encountered brackets straight after the type name before


Czar Flavius(Posted 2008) [#6]
It converts something to something. Lists store objects, so when you get something out of it in this manner, the first() method returns an object, so it needs to converted to wizard. The technical term is casting.

Edit: a 'use': if wizard extends character, then you might sometimes have a character variable that can store any dependent, or a wizard variable that can store wizards only. Depending upon what it's going into, you need to use either character(blah) or wizard(blah).


slenkar(Posted 2008) [#7]
thanks that makes it clearer