I saw the List behavior mentioned by a speaker in a Scala lecture video. Then thought I would try it with a Map. Also, seeing the same resolution of types via/through another type.
I'm curious to how this resolution works? Was this intended on the part of the Scala language/compiler team? Interested quirk that popped up? Will this function the same way in Dotty but with different syntax? Is there something special about the way List and Map are defined that says basically I can perform like a function and exchange one type for another?
Here is some sample code to illustrate what I am talking about:
// I'm being verbose to stress the types
implicit val theList: List[String] = List("zero", "one", "two", "three")
implicit val theMap: Map[Double, String] = Map(1.1 -> "first", 2.1 -> "second")
def doExample(v: String): Unit = {
println(v)
}
doExample(1)
// prints "one"
doExample(1.1)
// prints "first"