Skip to content

Instantly share code, notes, and snippets.

Created August 3, 2017 15:51
What would you like to do?
implicit val optionInt: Option[Int] = Some(1)
implicit val optionBoolean: Option[Boolean] = Some(true)
def getImplicitOptionInt(implicit oInt: Option[Int]): Int = oInt.get
def getImplicitOptionBoolean(implicit oBoolean: Option[Boolean]): Boolean = oBoolean.get
def getImplicitlyOptionA[A: Option]: A = implicitly[Option[A]].get
trait Parent {
def sayHello: String
trait Son extends Parent {
override def sayHello: String = "Hello! I'm Son!"
trait Daughter extends Parent {
override def sayHello: String = "Hello! I'm Daughter!"
def sayHello[A <: Parent](a: A): Unit = println(a.sayHello)
sayHello(new Son {})
sayHello(new Daughter {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment