In this chapter we’ll look at the following:
- Anonymous functions or lambdas.
- How anonymous classes differ from anonymous functions.
- First-class and higher-order functions.
- The differences between a function and a method.
- The differences between lambdas and closures.
A function in the general sense is a code fragment designed to perform a specific task or calculation. You can create a function as a Java method or a Scala def. Both by their nature are named. Anonymous functions, on the other hand, do not have a name.
An anonymous function is also called a lambda and when used can ...