Lambda expressions revisited
In this section, we will explore the syntax of lambda expression in more depth. So far, we used them without formally describing them. We will also examine other forms they can take.
As mentioned earlier, a lambda expression is essentially an anonymous function. They can be passed to another function or method, returned from a function or a method, and assigned to variables.
A lambda expression consists of an optional parameter list, followed by the lambda operator, and then a body. The lambda operator is a dash followed by the greater than symbol. The body of a lambda expression may be one or more statements and may optionally return a value.
Let's examine several variations of a simple lambda expression. A single value ...
Get Learning Java Functional Programming 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.