Call an object method: Difference between revisions
Content added Content deleted
imported>Acediast (→{{header|COBOL}}: added params) |
imported>Acediast (→{{header|COBOL}}: switched to free format) |
||
Line 238: | Line 238: | ||
(. 1 (equals 2)) ; alternative style</syntaxhighlight> |
(. 1 (equals 2)) ; alternative style</syntaxhighlight> |
||
=={{header|COBOL}}== |
=={{header|COBOL}}== |
||
{{Works with|COBOL 2002}} |
|||
There are two ways to invoke a method: the <code>INVOKE</code> statement and inline method invocation. |
|||
<syntaxhighlight lang=" |
<syntaxhighlight lang="cobolfree">*> INVOKE statements. |
||
INVOKE my-class "some-method" *> Factory object |
|||
USING BY REFERENCE some-parameter |
|||
RETURNING foo |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
*> Factory object |
|||
⚫ | |||
*> Instance object</syntaxhighlight> |
|||
To call factory methods of objects of an unknown type (such as when you may have a subclass of the class wanted), it is necessary to get a reference to the class's factory object by calling the <code>"FactoryObject"</code> method. |
To call factory methods of objects of an unknown type (such as when you may have a subclass of the class wanted), it is necessary to get a reference to the class's factory object by calling the <code>"FactoryObject"</code> method. |
||
<syntaxhighlight lang=" |
<syntaxhighlight lang="cobolfree">INVOKE some-instance "FactoryObject" RETURNING foo-factory |
||
*> foo-factory can be treated like a normal object reference. |
|||
INVOKE foo-factory "someMethod"</syntaxhighlight> |
|||
=={{header|CoffeeScript}}== |
=={{header|CoffeeScript}}== |