On Saturday, 25 July 2020 at 18:24:22 UTC, Jesse Phillips wrote:
On Saturday, 25 July 2020 at 14:47:01 UTC, aberba wrote:
On Saturday, 25 July 2020 at 13:28:34 UTC, Adam D. Ruppe wrote:
On Saturday, 25 July 2020 at 11:12:16 UTC, aberba wrote:
Oop! Chaining the writeln too could have increased the wow
factor. I didn't see that.
oh I hate it when people do that though, it just looks off to
me at that point.
Ha ha. If you're writing idiomatic D code, why not not all in
on it?
It bugs me too, though I have done it.
I think the right answer of why it is odd is because writeln is
void. As soon as it is placed on the end the chain is broken
and you can't expand on it.
This is no different from any other "sink" that consumes a range:
someSource
.map!foo
.filter!bar
.splitter(baz)
.each!quux;
`each` returns void [1], so using it ends the chain. But that's
not a problem, because the whole *point* of using `each` is to
consume the range.
[1] Not exactly, but close enough.