Read Complete File to Array of Lines

Steven Schveighoffer schveiguy at yahoo.com
Fri May 11 11:57:52 PDT 2012


On Fri, 11 May 2012 11:00:16 -0400, Paul <phshaffer at gmail.com> wrote:

> I would like to read a complete file in one statement and then process  
> it line by line.
>
> foreach (line; MyFile)
> etc.
>
> Is it possible to read a file into and array of lines?
> Thanks

Would something like this work?

auto arr = array(map!"a.idup"(File("file.txt").byLine()));

-Steve


More information about the Digitalmars-d-learn mailing list