Scala Map, ambiguity between tuple and function argument list -


val m = scala.collection.mutable.map[string, int]() // doesn't work m += ("foo", 2) // work m += (("foo", 2)) // works val barpair = ("bar", 3) m += barpair 

so what's deal m += ("foo" , 2) not working? scala gives type error:

 error: type mismatch;  found   : java.lang.string("foo")  required: (string, int)        m += ("foo", 2)              ^ 

apparently scala thinks trying call += 2 arguments, instead of 1 tuple argument. why? isn't unambiguous, since not using m.+= ?

unfortunately a b (c, d, e, ..) desugars a.b(c, d, e, ..). hence error.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -