Prev | Current Page 240 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

now().getTime();
}
public function publish() : Void
{
publishedOn = Date.now();
}
public function unpublish() : Void
{
publishedOn = null;
}
}
class BlogEntry extends BaseEntry { }
class Article extends BaseEntry { }
(continued)
117
Chapter 5: Delving Into Object-Oriented Programming
Super
When a class is extended, a new super identifier is accessible. It is very similar to the this identifier but
refers to the parent class and not to the current one. As for the this identifier it can be omitted when
there are no ambiguities. Consider this example:
class Main
{
static function main()
{
var test = new B();
trace(test.getText());
}
}
class A
{
public function new() { }
public function getAbc() : String
{
return ???ABC???;
}
}
class B extends A
{
public function getText() : String
{
return getAbc();
}
}
The function call getAbc() is equivalent to this.getAbc() and to super.getAbc() .
Functions Override
When extending a class it can be useful to redefine the behavior of certain functions.


Pages:
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252