Jump to content

Delegates: Difference between revisions

Line 1,345:
=={{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: operation
{
@delegate respondTo(#thing) ifTrue: [ @delegate thing return ]
"Default implementation" println ;</lang>
}</lang>
Usage :
 
1,015

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.