Reputation: 15872
I'm creating a new class where I inherit from mutable.Map
:
class Env extends mutable.Map[String, Any] {
var outer = new mutable.Map[String, Any]
def get(name: String): Any = if (super.get(name).isEmpty) outer.get(name) else super.get(name)
}
The error I get is:
Test.scala:6: error: method get in trait MapLike is accessed from super. It may not be abstract unless it is overridden by a member declared `abstract' and `override'
Why?
Upvotes: 1
Views: 302
Reputation: 40461
mutable.Map
is a trait whose get
method is not implemented (ie. abstract).
You should rather extends mutable.HashMap
. However, keep in mind that maps get
methods return an Option and not directly the stored value.
Upvotes: 3