0

How can I assign a default value for a function parameter of type Class in Action script 3

    public function foo(param:Class = ????? )
    {

    }

Thanks

1 Answer 1

1

You can't, but here's a workaround to achieve the same effect:

public function foo(param:Class = null ):void
{
    if(!param) 
    {
        // this'll be your default class
        param = MyClass;
    }
    //  here you can do: var bar:* = new param();
}
Sign up to request clarification or add additional context in comments.

1 Comment

You can also add an undefined acceptance of variables to your function and use it as an array. public function foo( ...args ):void { trace ( args ); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.