---
# System prepended metadata

title: Untitled

---


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


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


sealed trait Option[+T] {    
    def isNone: Boolean
    def map[B](f: T => B): Option[B] = fold(None)(a => Some(f(a))
    
    def flatMap[B](f: T => Option[B]): Option[B] = fold(None)(f)
    
    def fold[B](default: => B)(present: T => B): B = this match {
        case Some(value) => present(value)
        case None => default
    }
    
}

object None extends Option[Nothing] {
  def isNone: Boolean = true
}

case class Some[T](value: T) extends Option[T] {
 def isNone: Boolean = false 
}

```




