Scala 3

Scala 2

For comprehension

In Scala, for comprehension is a syntax sugar of a sequence of following methods

Specify interface implemented by lambda explicitly

// differentiate it from Supplier[Boolean]
{ () => true }: java.util.function.BooleanSupplier