Possible Duplicate:
Adding a tuple to a set does not work
I have this code:
class A
var buffer = Buffer[(A, Int)]()
then, somewhere:
val a = new A
buffer += (a, 0) // error
the type inferencer fails on a in (a, 0) telling that I pass A when I must pass (A, Int):
scala> def make {
| val a = new A
| buffer += (a, 0)
| }
<console>:11: error: type mismatch;
found : A
required: (A, Int)
buffer += (a, 0)
^
however if I do this:
val a = new A
val tuple = (a, 0)
buffer += tuple
the error is gone. Is this some kind of bug or am I missing something?
The compiler does not know, whether you mean buffer.+=(a,0) or buffer += Tuple2(a,0) here.
possible solutions: