In REPL:
import collection.mutable.{ HashSet, SynchronizedSet }
var myPool = new HashSet[String] with SynchronizedSet[String]
myPool += "oh"
myPool += "yes"
myPool = myPool.tail
and I get:
error: type mismatch;
found : scala.collection.mutable.HashSet[String]
required: scala.collection.mutable.HashSet[String] with scala.collection.mutable.SynchronizedSet[String]
myPool = myPool.tail
^
What am I doing wrong?
Just what the message says,
myPool.tailhas typeHashSet[String], and your variableMyPoolis declaredHashSet[String] with SynchronizedSet[String]You just need to declare the type you want to avoid the too precise inferred one.
Note that on a mutable set,
tailis a costly operation and returns you a new Set. That might not be what you want. (Moreover, the spec is mute as to which element will be removed)