While trying to make a map in Scala, I receive the following error message: object Map is not a value
The code I’m using is the following:
val myStringMap = Map[String, String]("first" -> "A", "second" -> "B", "third" -> "C")
I am quite puzzled as to why I cannot create this map because after looking at Scala documentation, it seems to me that the syntax of my code is proper.
When you see the error “object is not a value” this typically means that the in-scope type is a Java type – you probably are importing
java.util.Mapin scopeBut
Remember, in scala each class comes with a (optional) companion object which is a value. This is not true of Java classes.