---
# System prepended metadata

title: Untitled

---


Implement a minimal `Option` that has `map` and `flatMap`.


```scala
import scala.{Option => _}
// implement here



sealed trait Option[+A] {
    def map[B](f: A => B): Option[B] = fold(None)(a => Some(f(a)))
    
    def flatMap[B](f: A => Option[B]): Option[B] = fold(None)(f)
    
    def fold[B](ifEmpty : => B)(f: A => B): B = this match {
        case Some(a) => f(a)
        case None => ifEmpty
    }
}

case class Some[+T](value: T) extends Option[T]
case object None extends Option[Nothing]


```

