Variable Length parameters

You might be aware of the fact that you can use a technique called Method Overloading.

This technique allows you to use the same method signature but with a different set of Method parameters.

Say you needed to give a different number of parameters to a function, you’d either have to implement the different methods, or make a list and pass the list to the function.

ActionScript 3 has a cool function which allows you to use just 1 method signature, and allow an indifferent number of parameters of the same type.

public static function showNumbers(… myNumbers):Number{
for (uint i=0; i< myNumbers.length; i++){

The key to all this is the “…” infront of the variable name in the parameter. You might see it as a kind of “here are the paramteres, etc… etc… 😉 )


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s