Why does File.byLine() return char[] and not string

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Oct 18 08:03:20 PDT 2015


On Friday, 16 October 2015 at 12:43:59 UTC, Meta wrote:
> On Friday, 16 October 2015 at 10:38:52 UTC, Shriramana Sharma 
> wrote:
>> Is there a particular reason that File.byLine() returns char[] 
>> and not string i.e. immutable(char)[]? Is it just to avoid 
>> being overly restrictive? It seems that having to .idup it is 
>> inefficient...
>
> byLine reuses an internal buffer for each line which gets 
> overwritten each iteration. The fact that it returns char 
> instead of string is meant to signal this to the user, to tell 
> them that the value they're getting back is mutable and subject 
> to change.

Sorry, but could you explain more simply? I reread all 
information, bit can't understand about what buffer you are 
talking. And what is "signal"? How it's working?


More information about the Digitalmars-d-learn mailing list