On Fri, Jun 20, 2008 at 12:11 AM, Zemian Deng <
keepitsimple12@...> wrote:
> 1) The online scaladoc
>
http://www.scala-lang.org/docu/files/api/index.html says for
> 2.7.1-final, but I just found out that scala.collection.mutable.Map
> has deprecated method += that's not showing on scaladoc. Can we have a
> matching doc?
The docs are correct. There are two += methods, and you happen to be
using the wrong (deprecated) one.
> 2) I like the old deprecated method better than the new suggested way.
> Is there better reason for this change other than require more typing?
> val m = new HashMap[String, Int]
> m += "one"->111 //warning: there were deprecation warnings; re-run
> with -deprecation for details
Try m += ("one" -> 111)
m += "one"->111 is the same as m.+=("one").->(111) - this usage
of += is deprecated
m += ("one" -> 111) is the same as m.+=("one" -> 111) - this is fine.
Once the precedence of the += operator method is fixed (in 2.7.2?),
this problem will go away - you'll have to make a deliberate effort to
invoke the deprecated case.
> m += ("two", 222) // and this product error!
Because you're calling m.+=("two", 222), passing two arguments to +=
where it wants just one.
Cheers,
Darshan