---
# 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]
    
    def flatMap[B](ff: A => F[B]): Option[B]
    
    def fold[C](c: => C)(f: A => C): Option[C]
}


case class Some[+A](value: A) extends Option[A] {
    def map[B](f: A => B): Option[B] = {
        Some(f(value))
    }
    
    def flatMap[B](ff: A => Option[B]): Option[B] = {
        ff(value)
    }
    
    def fold[C](c: => C)(f: A => C): Option[C] = {
        map(f)
    }
    
}
case object None extends Option[Nothing] {
    
    def map[B](f: A => B): Option[B] = None
    
    def flatMap[B](ff: A => B): Option[B] = None
    
    def fold[C](c: => C)(f: A => C): Option[C] = {
        Some(c)
    }

}










```