我写了一个与此非常相似的函数:
def writeMyEl (x: TypeA, y: TypeB, z : TypeC) {
if (myMutableHashMap.contains((x, y)))
myMutableHashMap(x, y) = z else
myMutableHashMap += (x, y) -> z
}
在实际代码中,类型A和B是枚举类型,C是一个case类。myMutableHashMap被定义为同一个类中writeMyEl
函数的类型为scala.collection.mutable.HashMap[(TypeA, TypeB), TypeC]
的val
。
Scala (2.8)编译器报告:
error: too many arguments for method update: (key: (TypeA, TypeB),value: TypeC)Unit
我做错了什么?