CDE
This commit is contained in:
parent
518da4a923
commit
764da6cbbb
6144 changed files with 83610 additions and 11 deletions
29
Task/Delegates/D/delegates-2.d
Normal file
29
Task/Delegates/D/delegates-2.d
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import tango.io.Stdout;
|
||||
|
||||
class Delegator
|
||||
{
|
||||
private char[] delegate() hasDelegate;
|
||||
public:
|
||||
char[] operation() {
|
||||
if (hasDelegate is null)
|
||||
return "default implementation";
|
||||
return hasDelegate();
|
||||
}
|
||||
|
||||
typeof(this) setDg(char[] delegate() dg)
|
||||
{
|
||||
hasDelegate = dg;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
int main(char[][] args)
|
||||
{
|
||||
auto dr = new Delegator();
|
||||
auto thing = delegate char[]() { return "delegate implementation"; };
|
||||
|
||||
Stdout ( dr.operation ).newline;
|
||||
Stdout ( dr.operation ).newline;
|
||||
Stdout ( dr.setDg(thing).operation ).newline;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue