string mixup problem with stdin.byLine

torea via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 10 00:12:51 PDT 2016


On Monday, 8 August 2016 at 12:29:51 UTC, Seb wrote:
>
> You should always carefully read the description and Notes ;-)
>
>> Note:
>> Each front will not persist after popFront is called, so the 
>> caller must copy its contents (e.g. by calling to!string) when 
>> retention is needed. If the caller needs to retain a copy of 
>> every line, use the byLineCopy function instead.
>
> http://dlang.org/phobos/std_stdio.html#.File.byLine
>
> Unfortunately you are not the first one who bumped into this 
> problem and this non intuitive behavior of byLine is heavily 
> disputed.

Duh... I've read the documentation but managed to jump over these 
explanations... reading carefully would have saved me some pain!
Hopefully I'll be more careful next time.


More information about the Digitalmars-d-learn mailing list