Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Delegates/Raku/delegates.raku
Normal file
28
Task/Delegates/Raku/delegates.raku
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
class Non-Delegate { }
|
||||
|
||||
class Delegate {
|
||||
method thing {
|
||||
return "delegate implementation"
|
||||
}
|
||||
}
|
||||
|
||||
class Delegator {
|
||||
has $.delegate is rw;
|
||||
|
||||
method operation {
|
||||
$.delegate.^can( 'thing' ) ?? $.delegate.thing
|
||||
!! "default implementation"
|
||||
}
|
||||
}
|
||||
|
||||
my Delegator $d .= new;
|
||||
|
||||
say "empty: "~$d.operation;
|
||||
|
||||
$d.delegate = Non-Delegate.new;
|
||||
|
||||
say "Non-Delegate: "~$d.operation;
|
||||
|
||||
$d.delegate = Delegate.new;
|
||||
|
||||
say "Delegate: "~$d.operation;
|
||||
Loading…
Add table
Add a link
Reference in a new issue