how to get first object in the list?

BlitzMax Forums/BlitzMax Programming/how to get first object in the list?

What's wrong with this... when I try to do:
Local template:TTemplate = TTemplateManager.templateList.First


I get the following error:
Compile Error: Unable to convert from 'Object()' to 'TTemplate'
Build Error: failed to compile D:/Dead Wake/development/_code/game.bmx


But all works (?) when I do:
for Local template:TTemplate = EachIn TTemplateManager.templateList
   TCharacterManager.CreateCharacter(template)
Next


TTemplate is my own class (Type TTemplate with some fields), and TTemplateManager has "Global templateList:TList = CreateList()"

What's the problem with 'first'? (and how to get the first item in this list?)

You need to cast the object to its original type:
Local template:TTemplate = TTemplate(TTemplateManager.templateList.First())


Now it said:

Compile Error: Unable to convert from 'Object()' to '<unknown>'
Build Error: failed to compile D:/Dead Wake/development/_code/game.bmx


?

Did you forget the parenthesis on .First()?

yep :)

...testing

EDIT: And it works. Thanks!