Ranges and Exception handling PR 2724

Robert burner Schadek via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 20 03:57:41 PST 2014


On Wednesday, 19 November 2014 at 05:49:55 UTC, H. S. Teoh via 
Digitalmars-d w
>>From what I understand, this PR is proposing to add a range 
>>wrapper that
> catches exceptions thrown from range primitives and passes them 
> to a
> user-specified handler. Seems to be a promising idea, but it's 
> probably

It is exactly that:

     auto s = "12,1337z32,54,2,7,9,1z,6,8";

     auto r = s.splitter(',')
         .map!(a => to!int(a))
         .handleBack!(ConvException, (e, r) => 0)
         .array;

     assert(equal(h, [12, 0, 54, 2, 7, 9, 0, 6, 8]));




More information about the Digitalmars-d mailing list