Sum informations in file....

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 24 11:30:58 PST 2014


On Mon, 24 Nov 2014 19:04:34 +0000
Suliman via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
wrote:

> I can't understand why foreach loop produce every line by line, 
> while it's fuctional analog print lines on one string:
the two samples are not the same, they doing completely different
things.

File.byLine returns *output* *range*. what `foreach` does is processing
this range element by element, while `writeln(range)` outputs the whole
range.

the second code means:

  auto lines = file.byLine();
  writeln(lines);

for `writeln` output range is a kind of array, so it outputs it as an
array.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20141124/71102674/attachment.sig>


More information about the Digitalmars-d-learn mailing list