Array as Parameter?
Monkey Forums/Monkey Programming/Array as Parameter?
| ||
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 |
| ||
Because they are names of different things? |
| ||
DoIt ([1,2,3,4,5]) |
| ||
Thank you Adam, this works! |
| ||
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. |