val m = scala.collection.mutable.Map[String,Int]() // this doesn't work m += ("foo",2) // this does work m += (("foo",2)) // this works too val barpair = ("bar",3) m += barpair
那么m =(“foo”,2)的处理无效吗? Scala给出了类型错误:
error: type mismatch; found : java.lang.String("foo") required: (String,Int) m += ("foo",2) ^
解决方法
不幸的是,b(c,d,e,..)去了a.b(c,..).因此错误.