Would someone help me understand why this does not work? Scala version 2.10
object ColorEnum {
sealed trait Color
case object Red extends Color
case object Blue extends Color
case object Green extends Color
}
Create a Map that accepts a Color as the Key and a String as a value
val colorMap = mutable.HashMap[ColorEnum.Color, String]()
Put an item on Map using ColorEnum as Key
colorMap.put(ColorEnum.Red, "Foo")
This throws an exception
error: type mismatch
found: ColorEnum.Red.type
required: ColorEnum.Color
I must be missing something with my understanding of how this should work.
Thanks