O'Reilly logo

Scala for Java Developers: A Practical Primer by Toby Weston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Toby Weston 2018
Toby WestonScala for Java Developershttps://doi.org/10.1007/978-1-4842-3108-1_10

10. Classes and Functions

Toby Weston
(1)
London, UK
 
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.

Anonymous Functions

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required