Questions about setters

P T Withington ptw at pobox.com
Thu Jul 24 13:30:19 PDT 2008


Can I override a setter?  Can I call the setter I override using  
super?  How exactly?

> class foo {
>   var barstate;
>   function set bar (value) { barstate = bar }
>   function get bar () { return barstate }
> }
>
> class annotatedFoo {
>   override function set bar (value) {
>     note('setting bar');
>     // how do I call my super?
>     super['set bar'](value);
>   }
>   override function get bar () {
>     note('getting bar');
>     // how do I call my super?
>     return super['get bar']();
>   }
> }

Can `super` by itself mean "call next method"?  That would seem like a  
useful shortcut, and avoid the question of how you call a method with  
a space in its name.



More information about the Es4-discuss mailing list