Skip to content

Instantly share code, notes, and snippets.

@alexandru

alexandru/sealed-trait-2.scala Secret

Created Oct 31, 2014
Embed
What would you like to do?
sealed trait Option[+T] {
def map[U](f: T => U): Option[U] = this match {
case Some(value) => Some(f(value))
case None => None
}
}
case class Some[+T](value: T) extends Option[T]
case object None extends Option[Nothing]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment