I’am leaning the scala programming 3rd .chapter 3 use set and map.
the code on the book said the ( a → b) just convert to (a,b) ,then i read the source code ,that’s true
however the fallowing code can’t be complied
val treasureMap = mutable.Map[Int, String]()
treasureMap += ( 1 -> "GO to island")
treasureMap += (2 -> "find big x on Ground")
treasureMap += (3 -> "dig")
//error ,replace with tuple
treasureMap += (4,"haha you find nothing")
treasureMap.foreach(println(_))
error info:
type mismatch;
found : Int(4)
required: (Int, String)
treasureMap += (4,“haha you find nothing”)
can anybody tell me why?thanks a lot