---
# 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 map[B](f: T => B): Option[B] = this match {
        case Some(a) => 
        case None => 
    }
    def flatMap[B](f: T => Option[B]): Option[B]
}

case class Some[T](value: T) extends Option[T] {
    def map[B](f: T => B): Option[B] = {
        flatMap(f(value)
    }
    def flatMap[B](f: T => Option[B]): Option[B] = {
        f(value)
    }
}

case object None extends Option[Nothing] {
    def map[B](f: Nothing => B): Option[B] = {
        None
    }
    def flatMap[B](f: Nothing => Option[B]): Option[B] = {
        None
    }
}
                
val aOpt = None
                
                val res = for{
                    a <- optA //some(4)
                    b <- optB //none 
                } yield (a, b)
                
                res // 

aOpt.map{
   a => a*2 
}
                
aOot.get                
                
                


val numOpt: Option[Int] = Some(5)

def stringify: Int => String

val res: Option[String] = numOpt.map(stringify)

Whatever <: Any
Nothing <: Whatever
val none: Option[???] = None
val x: Option[Int] = none     // Option[???] <: Option[Int]
val y: Option[String] = none  // Option[???] <: Option[String]

sealed trait Animal
case object Dog extends Animal

Dog <: Animal
Option[Dog] <: Option[Animal]
print(Option(Dog))

def print(animal: Option[Animal]): String = 


```