Delegates: Difference between revisions
Content added Content deleted
Line 2,429: | Line 2,429: | ||
subclass:#Thingy |
subclass:#Thingy |
||
instanceVariableNames:'' |
instanceVariableNames:'' |
||
classVariableNames:'' |
|||
poolDictionaries:'' |
|||
thing |
thing |
||
^ 'thingy implementation' |
^ 'thingy implementation'</lang> |
||
</lang> |
|||
Definition of the delegator: |
Definition of the delegator: |
||
<lang smalltalk> |
<lang smalltalk> |
||
Line 2,440: | Line 2,437: | ||
subclass:#Delegator |
subclass:#Delegator |
||
instanceVariableNames:'delegate' |
instanceVariableNames:'delegate' |
||
classVariableNames:'' |
|||
poolDictionaries:''. |
|||
delegate:something |
delegate:something |
||
Line 2,449: | Line 2,444: | ||
^ delegate |
^ delegate |
||
perform:#thing |
perform:#thing |
||
ifNotUnderstood:'default implementation'. |
ifNotUnderstood:'default implementation'.</lang> |
||
</lang> |
|||
Sample use: |
Sample use: |
||
<lang smalltalk> |
<lang smalltalk> |
||
Line 2,460: | Line 2,454: | ||
d delegate:(Thingy new). |
d delegate:(Thingy new). |
||
d operation. |
d operation. |
||
-> 'thingy implementation' |
-> 'thingy implementation'</lang> |
||
</lang> |
|||
=={{header|Swift}}== |
=={{header|Swift}}== |