Chapter 5. Programming with lambdas

This chapter covers

  • Lambda expressions and member references
  • Working with collections in a functional style
  • Sequences: performing collection operations lazily
  • Using Java functional interfaces in Kotlin
  • Using lambdas with receivers

Lambda expressions, or simply lambdas, are essentially small chunks of code that can be passed to other functions. With lambdas, you can easily extract common code structures into library functions, and the Kotlin standard library makes heavy use of them. One of the most common uses for lambdas is working with collections, and in this chapter you’ll see many examples of replacing common collection access patterns with lambdas passed to standard library functions. You’ll also ...

Get Kotlin in Action now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.