how to convert from Object to UDT

BlitzMax Forums/BlitzMax Programming/how to convert from Object to UDT

racingspider(Posted 2007) [#1]
Hi!
I have a collection of user defined types in a TList. But when I try access the first item in the list:

Local counter:BaseCounter
counter = hero.counters.First()
...

I get a compile error, "Unable to convert from 'Object' to 'BaseCounter'

How do you convert types? I can't seem to find that functionality.


watusimoto(Posted 2007) [#2]
Try:

counter = BaseCounter( hero.counters.First() )


racingspider(Posted 2007) [#3]
aha. Very good. THAT's how you convert types. Interesting. I was looking for a function to do it instead, but this does the job perfectly. Thanks!


watusimoto(Posted 2007) [#4]
Yeah, it took me a long while to stumble upon that trick.