Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,24 @@
class Delegator {
string delegate() hasDelegate;
string operation() {
if (hasDelegate is null)
return "Default implementation";
return hasDelegate();
}
typeof(this) setDg(string delegate() dg) {
hasDelegate = dg;
return this;
}
}
void main() {
import std.stdio;
auto dr = new Delegator;
string delegate() thing = () => "Delegate implementation";
writeln(dr.operation());
writeln(dr.operation());
writeln(dr.setDg(thing).operation());
}

View 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;
}