25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

##super Syntax<br />

21.4 ##super Syntax<br />

Suppose that a subclass method overrides a superclass method. From within the subclass<br />

method, you can use the ##super() syntax to invoke the overridden superclass method.<br />

Note:<br />

##super is case sensitive and must be in all lowercase.<br />

For example, suppose that the class MyClass.Down extends MyClass.Up and overrides the<br />

Simple class method. If the code for MyClass.Up.Simple is:<br />

ClassMethod Simple()<br />

{<br />

Write "Superclass.",!<br />

}<br />

and the code for MyClass.Down.Simple is:<br />

ClassMethod Simple()<br />

{<br />

Write "Subclass.",!<br />

Do ##super()<br />

}<br />

then the output for subclass method, MyClass.Down.Simple, is:<br />

>Do ##Class(MyClass.Down).Simple()<br />

Subclass.<br />

Superclass.<br />

><br />

##super also works with methods that accept arguments. For example, if the code for<br />

MyClass.Up.SelfAdd is:<br />

ClassMethod SelfAdd(Arg)<br />

{<br />

Write Arg,!<br />

Write Arg + Arg<br />

Quit<br />

}<br />

then its output is:<br />

>Do ##Class(MyClass.Up).SelfAdd(2)<br />

2<br />

4<br />

><br />

If the code for MyClass.Down.SelfAdd is:<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 183

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!