What do Ruby’s Enumerable module, .NET LINQ, and the new Java Stream package have in common? They are all there to facilitate functional programming. Here’s an example, pulled from Java 8’s docs because its support is the most recent.
int sum = widgets.stream() .filter(b -> b.getColor() == RED) .mapToInt(b -> b.getWeight()) .sum();
Chances are, you’ve been seeing a lot of this sort of code recently. I’m sure you’ll see more of it.
To me, its a very attractive style. It nearly eliminate...
Published on April 27, 2015 18:35