Cast Object to Array?

BlitzMax Forums/BlitzMax Programming/Cast Object to Array?

Beaker(Posted 2009) [#1]
I can pass an Array as an Object function parameter:

Function myFunction(arr:Object)
'what goes here?
End Function

Local myArr:Int[2]
myArr[0] = 12
myArr[1] = 13

myFunction(myArr)

But how do I access the array?

Thanks.


Brucey(Posted 2009) [#2]
Surprisingly, it works just like any other cast :
SuperStrict

Function myFunction(arr:Object)
	Local array:Int[] = Int[](arr)
	
	Print array.length
	Print array[1]
End Function

Local myArr:Int[2]
myArr[0] = 12
myArr[1] = 13

myFunction(myArr)


BlitzMax is cool :-)


Beaker(Posted 2009) [#3]
Thanks. I thought I'd tried that, but obviously not. :)