Created
May 25, 2018 08:51
-
-
Save jimmydivvy/6b563fa4aa39796284eef17742575230 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object ExistentialTest { | |
case class Box[T]() | |
case class Pair[T](a: Box[T], b: Box[T]) | |
val pair: Pair[_] = ??? | |
val pair2 = Pair(pair.a, pair.b) | |
} |
AndreasKostler
commented
May 25, 2018
•
object ExistentialTest {
import scala.language.existentials
case class Box[T](value: T)
case class Pair(a: Box[T] forSome { type T } , b: Box[T] forSome { type T } ) {
}
val pair: Pair = Pair(Box[Int](42), Box[Int](42))
val pair2 = Pair(pair.a, pair.b)
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment