在 scala 中使用泛型时出错:
import scala.collection.mutable
class test {
val car = mutable.Map.emprty[String, (Int,Int)]
read[String, (Int,Int)] ("file.txt",car)
def read[T,V] (fileName:String, mapName: mutable.Map[T,V]) {
mapName("abc") = (1,2)
}
错误:
error: type mismatch
found: java.lang.String("abc")
required: T