-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
The recently updated getOrElse example at the top of options.md uses upper bounds. We need to describe them!
sealed trait Option[+A] {
def getOrElse[B >: A](default: B): B
def isEmpty: Boolean
def isDefined: Boolean = !isEmpty
// other methods...
}
final case class Some[A](x: A) extends Option[A] {
def getOrElse[B >: A](default: B) = x
def isEmpty: Boolean = false
// other methods...
}
case object None extends Option[Nothing] {
def getOrElse[B >: Nothing](default: B) = default
def isEmpty: Boolean = true
// other methods...
}
Metadata
Metadata
Assignees
Labels
No labels