Getting a total from a user defined variable

Steven Schveighoffer schveiguy at gmail.com
Thu Apr 20 23:18:24 UTC 2023


```d
writeln("Total: ", p.fold!((a,b) => a+b.age)(0UL));
// or
writeln("Total: ", reduce!((a,b) => a+b.age)(0UL, p));
```

Note that `reduce` is the old version of `fold`, which happened when 
UFCS became a thing.

-Steve


More information about the Digitalmars-d-learn mailing list