Object is not a value error in scala

后端 未结 4 755
礼貌的吻别
礼貌的吻别 2020-12-18 21:14

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:

         


        
4条回答
  •  长情又很酷
    2020-12-18 21:57

    Just found this so maybe it will be useful to share my solution. If you have imported java.util.Map and need to use scala.collection.immutable.Map then use it with the full name so instead of

     Map(1 -> "one")
    

    do

    scala.collection.immutable.Map(1 -> "one")
    

    This way it will know what you mean

提交回复
热议问题