1 Reply Latest reply on Apr 4, 2008 7:47 AM by Caffeinerabbit

    Overriding a rest parameter

    Caffeinerabbit Level 1
      I have a method in a parent class that I need to override in a child, but the parent's version of the method uses a rest (...) parameter as its only argument.

      Since the argument arrives in the overridden class as an array, how do I then pass that data on to the original method (i.e. super.function())? Is there any way to indicate that an array should be treated like a rest parameter?

      I've since solved my application specific issue using a different approach, but I wasn't able to find anything that addressed the problem above in the Docs.
        • 1. Re: Overriding a rest parameter
          Caffeinerabbit Level 1
          Alex Harui over on FlexCoders graciously answered this one for me, so I'll post the answer here in case anyone else ever needs the reference.

          To pass a rest parameter, do the following:

          override public function foo(... rest):void
          {
          super.foo.apply(this, rest);
          }

          The apply() method is a member of the Function class, and is an alternate means of calling a method. The first parameter is a reference to your object, and the second is an array containing an arbitrary number of arguments.