Generic Constraints: Lower Bound

It is possible in Scala though. This is from the Scala stdlib’s Option type:

def orElse[B >: A](alternative: => Option[B]): Option[B]

Here [B >: A] indicates a type parameter B with a lower type bound (B must be a Supertype of A or the same type). The opposite and more common thing would be [B <: A] in Scala.

Horrible syntax though :zipper_mouth_face:

1 Like