Treat None like false

Sorry I should have been clearer - the Option class has one type parameter A, so the A in that method signature refers to whatever type the Option was constructed with. This will be the same type that the get method returns. The convention in Scala is to name type parameters as uppercase letters starting from A.

But from the Scala point of view, there is no function.

I don’t understand what you mean by this. Any time that you see something like A => B or (A, B) => C in a type ascription, this refers to a function type. It’s actually shorthand for Function1[A, B] and Function2[A, B, C] respectively. So when you see A => Option[B] as in the flatMap signature there certainly is a function.

I think I understand what you were talking about in your previous post now though - I didn’t see the by-name arrow in the type of b: => Option[T], apologies.

1 Like