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

val street1:Option[String] = ..
val street2:Option[String] = ..

val twoStreets:Option[(String,String)] = for {
    one <- street1
    two <- street2
} yield (one,two )

street1.flatMap(s=>street2.map(x=>(s,x)))

case class Some[A](value:A) extends Option[A]{
    
}



case object None extends Option[Nothing]
    



val street = Some(Some("Rakowska"))
val foo: Option[Int] = None

street.flatMap(s: Option[Option[String]] => s.toUppercase)  

//

Some("RAKOWSKA")


// Any 

// Nothing

T <: Any
Option[T] <: Option[Any]

??? <: T
Option[???] <: Option[T]
// Nil 

//Object


