---
# 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, value => Some(f(value)))
    }
    
    def fold[B](ifEmpty: => B, ifSome: A => B): B = {
        this match {
            case Some(value) => ifSome(value)
            case None => ifEmpty
        }
    }
    
    def flatMap[B]( f: A => Option[B]): Option[B] = {
        fold(None, f)
    }
}
case class Some[A](value: A) extends Option[A] 
case object None extends Option[Nothing]


