The trailing closure is beautiful!

Jacob Carlborg doob at me.com
Tue Dec 8 11:14:19 UTC 2020


On Tuesday, 8 December 2020 at 05:06:37 UTC, zoujiaqing wrote:

> How is this implemented in D?

D does not support trailing closures. But I've talked about that 
several times in the past [1][2][3]. Even did a proof of concept 
implementation. I'm all in favor of adding trailing closures or 
trailing delegates to D.

To implement the same in D you would have to pass the delegate 
within the parentheses:

Column({
     Text(artist.name);
     Text(artist.lastSeenOnline)
});

[1] https://forum.dlang.org/post/nfuurs$1kh7$1@digitalmars.com
[2] https://forum.dlang.org/post/mo6c8d$2o2a$1@digitalmars.com
[3] https://forum.dlang.org/post/mfguhp$2bmn$1@digitalmars.com

--
/Jacob Carlborg


More information about the Digitalmars-d mailing list