Re: What is a sink delegate?

2014-10-10 Thread Joel via Digitalmars-d-learn
Thanks thedeemon. On Friday, 10 October 2014 at 04:42:04 UTC, thedeemon wrote: On Friday, 10 October 2014 at 03:06:33 UTC, Joel wrote: How do you use that toString? Maybe an example? void main() { Try t = Try("Joel", 35); t.toString(s => writeln(s)); }

Re: What is a sink delegate?

2014-10-10 Thread VaZyJeanPierre via Digitalmars-d-learn
On Friday, 10 October 2014 at 11:35:21 UTC, Hjkp wrote: On Friday, 10 October 2014 at 04:42:04 UTC, thedeemon wrote: On Friday, 10 October 2014 at 03:06:33 UTC, Joel wrote: How do you use that toString? Maybe an example? void main() { Try t = Try("Joel", 35); t.toString(s =>

Re: What is a sink delegate?

2014-10-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/10/14 11:20 AM, Ali Çehreli wrote: On 10/10/2014 06:30 AM, Steven Schveighoffer wrote: > The const outside is irrelevant to whether it will accept it or not, > that is a contract between the toString function and your object. If you > want a non-const toString, I think that should work.

Re: What is a sink delegate?

2014-10-10 Thread Ali Çehreli via Digitalmars-d-learn
On 10/10/2014 06:30 AM, Steven Schveighoffer wrote: > On 10/10/14 1:00 AM, Ali Çehreli wrote: >> On 10/09/2014 08:06 PM, Joel wrote: >>> On Tuesday, 30 September 2014 at 17:27:09 UTC, Adam D. Ruppe wrote: >>>> On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Wil

Re: What is a sink delegate?

2014-10-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/10/14 1:00 AM, Ali Çehreli wrote: On 10/09/2014 08:06 PM, Joel wrote: On Tuesday, 30 September 2014 at 17:27:09 UTC, Adam D. Ruppe wrote: On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return "foo&quo

Re: What is a sink delegate?

2014-10-10 Thread Hjkp via Digitalmars-d-learn
On Friday, 10 October 2014 at 04:42:04 UTC, thedeemon wrote: On Friday, 10 October 2014 at 03:06:33 UTC, Joel wrote: How do you use that toString? Maybe an example? void main() { Try t = Try("Joel", 35); t.toString(s => writeln(s)); } I think that the problem pointed by the

Re: What is a sink delegate?

2014-10-09 Thread Ali Çehreli via Digitalmars-d-learn
On 10/09/2014 08:06 PM, Joel wrote: On Tuesday, 30 September 2014 at 17:27:09 UTC, Adam D. Ruppe wrote: On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return "foo"; } for example, you would use: voi

Re: What is a sink delegate?

2014-10-09 Thread thedeemon via Digitalmars-d-learn
On Friday, 10 October 2014 at 03:06:33 UTC, Joel wrote: How do you use that toString? Maybe an example? void main() { Try t = Try("Joel", 35); t.toString(s => writeln(s)); }

Re: What is a sink delegate?

2014-10-09 Thread Joel via Digitalmars-d-learn
On Tuesday, 30 September 2014 at 17:27:09 UTC, Adam D. Ruppe wrote: On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return "foo"; } for example, you would use: void toString(void delegate(string) si

Re: What is a sink delegate?

2014-09-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/30/14 1:22 PM, Gary Willoughby wrote: What is a sink delegate? Discussed here: http://forum.dlang.org/thread/m0bdgg$1t7j$1...@digitalmars.com?page=6#post-m0emvc:242av5:241:40digitalmars.com Aside from Adam's answer, the term 'sink' means to draw out something, as in

Re: What is a sink delegate?

2014-09-30 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 30 September 2014 at 17:22:44 UTC, Gary Willoughby wrote: What is a sink delegate? Instead of string toString() { return "foo"; } for example, you would use: void toString(void delegate(string) sink) { sink("foo"); } The sink argument there is then free to

What is a sink delegate?

2014-09-30 Thread Gary Willoughby via Digitalmars-d-learn
What is a sink delegate? Discussed here: http://forum.dlang.org/thread/m0bdgg$1t7j$1...@digitalmars.com?page=6#post-m0emvc:242av5:241:40digitalmars.com