【发布时间】:2011-12-12 13:53:05
【问题描述】:
在 REPL 中:
import collection.mutable.{ HashSet, SynchronizedSet }
var myPool = new HashSet[String] with SynchronizedSet[String]
myPool += "oh"
myPool += "yes"
myPool = myPool.tail
我得到:
error: type mismatch;
found : scala.collection.mutable.HashSet[String]
required: scala.collection.mutable.HashSet[String] with scala.collection.mutable.SynchronizedSet[String]
myPool = myPool.tail
^
我做错了什么?
【问题讨论】:
-
请注意
tail不会同步。这将是一个新的集合,实例化时没有SynchronizedSet特征。
标签: scala set hashset synchronized