On Thursday, 21 January 2016 at 14:36:36 UTC, Rikki Cattermole
wrote:
On 22/01/16 3:07 AM, W.J. wrote:
On Thursday, 21 January 2016 at 13:15:46 UTC, Rikki Cattermole
wrote:
[...]
Thanks for your reply.
So writeln consumes the values in an InputRange. That leads me
to
believe that if I feed an InputRange to foreach, it will
consume the
values, too.
Did I get that right ?
Correct.
If that's the case, why I can iterate and write the values
just fine
using nested foreach loops *and* writeln them afterwards ?
I would expect the foreach loops leaves "step3" in the same
state as
writeln does.
So I'm still a little confused as to how foreach goes about
it. I
thought foreach would be iterating an InputRange the same way
writeln does.
By attaching ".array" to the result of I was under the
impression the
result was actually converted to an array.
That seems not to be the case. What I probably got was
something like an
array of arrays of groups - which are apparently InputRanges ?
So, yes, writeln... InputRange... makes perfect sense except
for the
foreach case.
Thanks again for the help :)
After playing around some more and apart from requiring much more
practice I think this topic can be marked as 'solved'. However, I
can't seem to find the edit button for my initial post.
Anyways, thanks for your contributions :) Very much appreciated!