I read a blog about existential type in Scala: Existential types in Scala
In this blog, he mentions an example:
Map[Class[T forSome { type T}], String] Map[Class[T] forSome { type T}, String] Map[Class[T], String] forSome { type T}
His explanation. "the third is a supertype of all types of cards for which there is some T such that they are Map [Class [T], String]. So, we have some type of fixed type for the keys on the map - it's just this time we donβt we know what it is. The middle one has keys of type Class [T] forSome {type T}. That is, his keys are classes that are allowed to have whatever value they want for their type. So this is what we really wanted to. "
The explanation is not easy to follow. What are the differences between the second and third in the sample code? Can someone give us some examples?
The blog also mentions that Map[Class[_], String] equivalent to the third in the example when we really want the second. Will this affect semantics when we use _ for the existential type?
source share