---
# 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 mapHelper[B](f: A => B): A => Option[B] = {
        f andThen Some.apply
        Some.apply compose f
    }
    
    
    def map[B](f: A => B): Option[B] = this fold(None, a => Some(f(a)))
    
    def flatMap[B](f: A => Option[B]): Option[B] = this fold (None, f)
    
    def fold[B](fnone: => B, f: A => B): B = this match {
        case Some(a) => f(a)
        case None => fnone
    }
}

case object None extends Option[Nothing]
case class Some[A](a: A) extends Option[A]

val noneInt: Option[Int] = None
val noneString: Option[String] = None
