Delegates: Difference between revisions

Content deleted Content added
No edit summary
Updated only the first D entry (I don't have Tango)
Line 389:
 
=={{header|D}}==
D has built-in delegates, so we can skip creating an additional
''Delegate'' object and pass a real delegate directly to '''Delegator'''.
 
<lang d>importclass std.stdio;Delegator {
 
class Delegator {
string delegate() hasDelegate;
 
Line 410 ⟶ 408:
 
void main() {
import std.stdio;
auto dr = new Delegator;
autostring delegate() thing = () => "Delegate implementation";
 
writeln(dr.operation());
writeln(dr.operation());
writeln(dr.setDg(thing).operation());
}</lang>
{{out}}
Outout:
<pre>Default implementation
Default implementation
Delegate implementation</pre>
 
===Version using Tango===
{{libheader|tango}}