Returning a Lambda Expression from a Lambda Expression

 
final​ Function<​String​, ​Predicate​<​String​>> startsWithLetter =
 
letter -> name -> name.startsWith(letter);

We can build lambda expressions that themselves return lambda expressions. The implementation of the Function interface here takes in a String letter and returns a lambda expression that conforms to the Predicate interface.

Get Functional Programming in Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.