The rest parameter can also be used with other required parameters.
package{ import flash.display.Sprite;
public class Main extends Sprite{ public function Main(){
// trace(sum()); // throws a runtime error. trace(sum(1,2,3,4,5)); // Displays: 15 } function sum(base:Number, ... numbers):Number { var result:Number = base; for each (var num:Number in numbers) { result += num;
} return result; } } }
Related Scripts with Example Source Code in same category :