June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
25
Task/Delegates/Sidef/delegates.sidef
Normal file
25
Task/Delegates/Sidef/delegates.sidef
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
class NonDelegate { }
|
||||
|
||||
class Delegate {
|
||||
method thing {
|
||||
return "delegate implementation"
|
||||
}
|
||||
}
|
||||
|
||||
class Delegator (delegate = null) {
|
||||
method operation {
|
||||
|
||||
if (delegate.respond_to(:thing)) {
|
||||
return delegate.thing
|
||||
}
|
||||
|
||||
return "default implementation"
|
||||
}
|
||||
}
|
||||
|
||||
var d = Delegator()
|
||||
say "empty: #{d.operation}"
|
||||
d.delegate = NonDelegate()
|
||||
say "NonDelegate: #{d.operation}"
|
||||
d.delegate = Delegate()
|
||||
say "Delegate: #{d.operation}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue