Another Minor Object Problem...
BlitzMax Forums/BlitzMax Beginners Area/Another Minor Object Problem...
| ||
Type TType Field x:Int Global List:TList=New TList Function Foo() Local o:Object=List.Last() Local bar:Int=o.x End Function End Type When compiling it says identifier 'x' not found. What would be the proper way to do this? |
| ||
You need to cast it as a TTypeType TType Field x:Int Global List:TList=New TList Function Foo() Local o:TType=TType(List.Last()) Local bar:Int=o.x End Function End Type |
| ||
Edit: Ignore me I just posted completely the wrong thing. Sorry. |
| ||
Yeah those list functions only ever return an "Object" Type even though you may have stored another type in them. You always have to Typecast the return result when using Last, First and some other commands. You don't need to type cast if going:For o:TType = eachin List |
| ||
Ah. Thanks. I hate the fact that this sort of thing isn't documented. |
| ||
Help->Language->Types mentions casting an object into a derived type, but yes, the documentation could be clearer. |