Can ListToArray return a specific object type?
BlitzMax Forums/BlitzMax Beginners Area/Can ListToArray return a specific object type?
| ||
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. |
| ||
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. |
| ||
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. |
| ||
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. |