Can't understand the application of delegates in toString() functions

Heisenberg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 7 08:40:12 PST 2016


On Monday, 7 November 2016 at 16:33:30 UTC, Adam D. Ruppe wrote:
> On Monday, 7 November 2016 at 16:22:17 UTC, Heisenberg wrote:
>> Why? How can a delegate which returns nothing be used as an 
>> array which is going to be printed on the screen?
>
> You pass the string to the delegate, which does whatever with 
> it somewhere else.
>
> So you call: `passed_delegate("your string");` and it can 
> forward it to writeln or whatever.

But how does it forward it if it's:

> void delegate(const(char)[]) sink // ?

It returns nothing, and just takes an array of characters as a 
parameter.. Just how does it print?..


More information about the Digitalmars-d-learn mailing list