Delegates: Difference between revisions

Content deleted Content added
Tim-brown (talk | contribs)
Franck (talk | contribs)
Line 1,118: Line 1,118:
return 0;
return 0;
}</lang>
}</lang>


=={{header|Oforth}}==
<lang Oforth>Object Class new: Delegate1

Object Class new: Delegate2
Delegate2 method: thing { "Delegate implementation" println }

Object Class new: Delegator(delegate)
Delegator method: initialize { := delegate }

Delegator method: thing
{
@delegate ifNotNull: [
@delegate respondTo(#thing) ifTrue: [ @delegate thing return ]
]
"Default implementation" println
}</lang>
Usage :

<lang Oforth>Delegator new(null) thing
Default implementation

Delegator new(Delegate1 new) thing
Default implementation

Delegator new(Delegate2 new) thing
Delegate implementation</lang>


=={{header|ooRexx}}==
=={{header|ooRexx}}==