Can ListToArray return a specific object type?

BlitzMax Forums/BlitzMax Beginners Area/Can ListToArray return a specific object type?

SofaKng(Posted 2007) [#1]
I have a TList that contains TPoint object typecasted to plain "Object".

I'm then using ListToArray to convert my TList into an array, but it's returning an Object[] array.

Can I somehow have ListToArray return a TPoint[] array?

Otherwise I need to typecast every single item in the Object[] array to a TPoint before using it.


grable(Posted 2007) [#2]
I just did a quick test, and it seems you can cast arrays!
I tried to do this when i first got max and it didnt work, did i miss an update or?

EDIT: sorry, i spoke to soon :( somehow blitz knows what type an array originaly has, so casting it to Object[] and back works. but casting from Object[] does not.


SculptureOfSoul(Posted 2007) [#3]
I'd just write my own version of list to array and have the casting take place while copying the objects from the list to the array.


Azathoth(Posted 2007) [#4]
I'm sure one of the early versions could, because after afew upgrades I noticed some of my code stopped working because I was casting the return of ListToArray.