This page is no longer maintained — Please continue to the home page at

++ ambiguous on Set[Any]

No replies
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

scala> Set[Any]("abc") ++ Set("def")
:5: error: ambiguous reference to overloaded definition,
both method ++ in trait Addable of type (Traversable[Any])scala.collection.immutable.Set[Any]
and method ++ in trait TraversableTemplate of type [B >: Any,That](Traversable[B])(implicit scala.collection.generic.BuilderFactory[B,That,scala.collection.immutable.Set[Any]])That
match argument types (scala.collection.immuta...
Set[Any]("abc") ++ Set("def")

But as long as the lhs isn't an Any set, it's okay with creating one:

scala> Set("abc") ++ Set(5)
res0: scala.collection.immutable.Set[Any] = Set(abc, 5)

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland