how to get first type in a list
BlitzMax Forums/BlitzMax Beginners Area/how to get first type in a list
| ||
Hi, how do you get the first type in a list? |
| ||
yourlist.first() returns the first object in the list. |
| ||
thanks |
| ||
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! |
| ||
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 |
| ||
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). |
| ||
thanks that makes it clearer |