Skip to content

Instantly share code, notes, and snippets.

@alexandru
Created October 31, 2014 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandru/2604948978c497adc8e2 to your computer and use it in GitHub Desktop.
Save alexandru/2604948978c497adc8e2 to your computer and use it in GitHub Desktop.
sealed trait Option[+T] {
def map[U](f: T => U): Option[U]
}
case class Some[+T](value: T) extends Option[T] {
def map[U](f: T => U) = Some(f(value))
}
case object None extends Option[Nothing] {
def map[U](f: T => U) = None
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment