I've been reading the scala eBook and found an example of adding a key value pair to a map:
map += (1 -> "Some String")
it seems that the (1 -> "Some String") results in a Tuple2, however the (1, "Some String") also results in a Tuple2, as follows:
scala> 1 -> "Some String"
res8: (Int, java.lang.String) = (1,Some String)
scala> res8 getClass
res10: java.lang.Class[_] = class scala.Tuple2
scala> (1, "Some String")
res11: (Int, java.lang.String) = (1,Some String)
scala> res11 getClass
res12: java.lang.Class[_] = class scala.Tuple2
The problem I have is understanding why map += (1 -> "Some String") works fine, but:
scala> map += (1, "Some String")
<console>:6: error: type mismatch;
found : Int(1)
required: (Int, String)
map += (1, "Some String")
^
gives me an error.
Thanks
Lorenz