Array as Parameter?

Monkey Forums/Monkey Programming/Array as Parameter?

Midimaster(Posted 2013) [#1]
why can't I do this?

DoIt [1,2,3,4,5]

Function DoIt:Void( Id%[])
   ....
End


at the moment only this works:

local Values:Int[] = [1,2,3,4,5]
DoIt Values

Function DoIt:Void( Id%[])
   ....
End


Is there a possibility to pass the given array without the help of a local variable


Gerry Quinn(Posted 2013) [#2]
Because they are names of different things?


AdamRedwoods(Posted 2013) [#3]
DoIt ([1,2,3,4,5])



Midimaster(Posted 2013) [#4]
Thank you Adam, this works!


Goodlookinguy(Posted 2013) [#5]
I'm going to leave this note here for anyone in the future who finds this thread and doesn't understand what happened.
First off, this...
DoIt [1,2,3,4,5]
...is the same as this.
DoIt[1,2,3,4,5]

Which makes the compiler think that you're trying to access an object in an array, of which the function 'DoIt' is not. That's why putting parenthesis around it deals with the problem by telling the compiler that it's an argument value, not an array accessor.