A very handy parameter is the rest one. Imagine you want a function that will calculate the sum of any number of parameters of type number. One way to do it is to send an array to the function. But one better way is to use the “rest” parameter.
Here is the function:
public function MakeSum(a:int, ... rest):int { var sum:Number = 0; for (var i:uint = 0; i < args.length; i++) { sum += args[i]; } return a+sum; } .... MakeSum(1,2,3); //returns 6 MakeSum(15,20); // returns 35
That is all
For more info look here.
Tags: flex, parameter, rest
This post was written by Virgil Cristea
Views: 2906










