---
# 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](fun :A => B): Option[B] = this match {
        case Some(value) => Some(fun(value))
        case None => None
    }
    
    def flatMap[B](func: A => Option[B]): Option[B] = this match {
        case Some(value) => fun(value)
        case None => None
    }
    
    def toString = this match {
        case Some(a) => "Some(" + a + ")"
        case None => "None"
    }
}

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


val x: Option[Int] = Some(10)
x.map(i => i * 2 : Int => Int): Option[Int] // Some(20)
x.map(i => i.toString: Int => String): Option[String] // Some("10")
x.map(i => Some(i*2)): Option[Option[Int]]
x.flatMap(i => Some(i*2)): Option[Int]

```