我是scala的新手。我希望在地圖被修改時得到通知。我認爲這可以使用可觀察的地圖來完成。scala中的observablemap
我試圖定義像下面
var myObj = new Map[UUID, MyType] with ObservableMap[UUID,MyType]
,但它不編譯說一個物體..
error: object creation impossible, since:
method iterator in trait MapLike of type => Iterator[(java.util.UUID, MyType)] is not defined
method get in trait MapLike of type (key: java.util.UUID)Option[MyType] is not defined
method -= in trait ObservableMap of type (key: java.util.UUID)this.type is marked `abstract' and `override', but no concrete implementation could be found in a base class
method += in trait ObservableMap of type (kv: (java.util.UUID, MyType))this.type is marked `abstract' and `override', but no concrete implementation could be found in a base class
爲什麼會這樣?你如何實例化一個ObservableMap?
行..這可能是愚蠢的..我應該宣佈它爲HashMap .. –