The rest parameter can also be used with other required parameters. : Function parameters : Function Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Function » Function parameters »

 

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;
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Function
» Function parameters