Alex Rivera | Logout

filling in (...rest) parameters with an array?

Asked 2009-03-12T00:04:37.490
9

Some as3 functions handle overloading by allowing for an arbitrary number of parameters using the convention:

public function doSomething( ... rest ):void;

I am in a situation where I need to pass all the values of an array (of arbitrary length) into this type of function... I am not sure how to do this. Suggestions?

Here is a hack solution, but it is not extensible:

switch (args.length) {
case 0: doSomething(); break;
case 1: doSomething(args[0]); break;
case 2: doSomething(args[0], args[1]); break;}
Edit
Report

1 Answer

1

Here is a very good tip to pass the rest parameter between functions.

answered 2012-09-11T08:03:07.467

Your Answer