What does func!thing mean?
Gary Willoughby
dev at nomad.so
Fri Nov 8 00:59:15 PST 2013
On Friday, 8 November 2013 at 05:46:29 UTC, ProgrammingGhost
wrote:
> I'm a D noob. ".map!(a => a.length)" seems like the lambda is
> passed into the template. ".map!split" just confuses me. What
> is split? I thought only types can be after "!". I would guess
> split is a standard function but then shouldn't it be
> map!(split)?
>
> const wordCount = file.byLine() // Read
> lines
> .map!split // Split
> into words
> .map!(a => a.length) // Count
> words per line
> .reduce!((a, b) => a + b); // Total
> word count
For a friendly introduction to D template system please take a
look at this: http://nomad.so/2013/07/templates-in-d-explained/
More information about the Digitalmars-d-learn
mailing list