how to convert from Object to UDT

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

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.

Try:

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

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!

Yeah, it took me a long while to stumble upon that trick.