Chaining input

Chris via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 8 04:00:00 PDT 2015


I have the following code that converts input like

blah, blub, gobble, dygook

to string[]

auto f = File("file.txt", "r");
auto words = f.byLine
                  .map!(
                    a => a.to!(string)
                          .splitter(", ")
                          .filter!(a => a.length)
                    )
                    .copy(appender!(string[])).data;

I'm sure there is room for improvement.

D is pretty cool in this way. Once you get used to this kind of 
code, you're spoiled forever.


More information about the Digitalmars-d-learn mailing list