假设我有下一张地图:
import scala.collection.mutable._
val countries = Map[String, String](
("Paris", "France"),
("Washington", "USA"),
("London", "England")
)
然后我尝试向该映射添加一些值(我从命令行参数获取值):
countries += (args(0), args(1))
但是上面的代码没有编译说
found : String
required: (String, String)
当我将其更改为
countries += ((args(0), args(1)))
或者
countries += (args(0) -> args(1))
然后它编译成功。为什么编译器在第一种情况下无法识别元组?