Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explicitly overriding constructors in ActionScript3

All,

I ran into this funny thing in a different post. It was pointed out to me that you can explicitly override a constructor... which doesn't seem necessary, and I am a little surprised it even compiles. Take a look:

public class TestClass
{
    public function TestClass() {}
}

public class TestClass2 extends TestClass
{
    public override function TestClass2() {}
}

Explicitly calling override on the constructor might just be a no-op, as it is certainly not necessary. My question: Is there a subtlety here that I am missing? Does explicitly overriding the constructor tell the compiler something?

like image 797
Brian Genisio Avatar asked Oct 26 '22 00:10

Brian Genisio


1 Answers

public class TestClass
{
    public function TestClass() {}
}

public class TestClass2 extends TestClass
{
    public override function TestClass2() {
       super();//this makes call to the default constructor
}
like image 69
sivasankar Avatar answered Oct 31 '22 01:10

sivasankar