http://weblog.mrinalwadhwa.com/2007/07/19/flex-tip-of-the-day-varargs-in-as3/
// Here’s a bare bone example:
private function average(... args):Number{
var sum:Number = 0;
for(var i:int = 0; i<args.length;i++){
sum += args[i];
}
return sum/args.length;
}
// Now all the below calls would work
var a:Number = average(100,200);
a = average(100,200,300);
a = average(100,200,300,400);
a = average(100,200,300,400,500);
No comments:
Post a Comment