Card 09/ 09

RecapDifficulty: Advanced1 min

Recap: Lambdas and Functional Interfaces

What a lambda is, the interfaces it lands in, method references and captured variables, with where each was.

Lambdas come down to the five ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
A lambda is an object implementing an interface, chosen by where it is passedLambdas: Passing Behaviour to a Method as an Argument
A functional interface has exactly one abstract methodFunctional Interfaces: Exactly One Abstract Method
Function, Predicate, Consumer and Supplier cover almost everythingFunction vs Predicate vs Consumer vs Supplier
A method reference replaces a lambda that only passes its parameters throughMethod References, and When a Lambda Is Clearer
Captured locals must never be reassigned, because the lambda holds a copyCaptured Variables: Why a Lambda Cannot Change a Local

A lambda has no type of its own. Its parameter types, its return type and what it may touch all come from the parameter it was handed to, and reading that parameter is how you read the lambda.