On 11/17/05, Tim Stickland <[EMAIL PROTECTED]> wrote:

> One thing that I noticed in your example code was that you called methods
> of the parent class using super.method() rather than this.method(). I
> wasn't
> aware you could do that, but it certainly makes reading the code more
> straightforward.


Not just more readable - consider the case where you're overriding
something:

class A
{
public function doSomething()
{
trace("Something in A");
}
}

class B extends A
{
public function doSomething()
{
super.doSomething();
trace("Something in B");
}
}

In this situation, using super.method() lets you call the parent
implementation of the method you're currently in. If you were limited to
this.method(), then you'd be trapped in an infinitely recursive loop as the
method kept calling itself...

In fact to do exactly this is normally the only time you'd use super.method().
If you're calling super.doSomethingElse() from your doSomething() function,
something is probably wrong with your OOP design...

Ian
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to