On Friday, 29 December 2017 at 20:11:03 UTC, Seb wrote:
On Friday, 29 December 2017 at 19:38:44 UTC, aliak wrote:
Hi,
So when I'm dealing with ranges, there're a number of times
where I get the front of the returned result of a set of
operations, but of course there is no front so you get an
runtime access error.
[...]
Do you know about the proposed `orElse`?
https://github.com/dlang/phobos/pull/5154
Oh cool. No I did not. Seems like a nice approach. It would incur
the creation of a new object when one doesn't exist, which I
guess would be fine for many situations, and would work for this
as well probably, but it'd be nice to avoid it as well in some
situations.
Just going thought std a bit now and I found this:
https://dlang.org/library/std/typecons/black_hole.html
That would be pretty cool to have
range.op!f.blackHoleFront.call() - though blackHoleFront sounds
horrible :p