I'm trying how to figure out and work with maps with enums as keys in Scala. Looking at this question, I can instantiate maps, but when I try to update the map in place, I get a type mismatch error. What is going on here?
object MyEnums extends Enumeration {
type MyEnum = Value
val BOB, TED, JEN = Value
}
var mymap = scala.collection.mutable.Map[MyEnums.Value, Long]()
mymap += (MyEnums.JEN -> 100L)
throws:
<console>:38: error: type mismatch;
found : (MyEnums.Value, Long)
required: (MyEnums.Value, Long)
mymap += (MyEnums.JEN -> 100L)
If I do the same thing, but use e.g. strings as the key type, this works as expected.
EDIT: These issues occur when using scala in spark-shell, not the normal scala repl.