What is the syntax for adding an element to a scala.collection.mutable.Map?

Viewed 132449

What is the syntax for adding an element to a scala.collection.mutable.Map ?

Here are some failed attempts:

val map = scala.collection.mutable.Map

map("mykey") = "myval"

map += "mykey" -> "myval"

map.put("mykey","myval")
7 Answers

var map:Map[String, String] = Map()

var map1 = map + ("red" -> "#FF0000")

println(map1)

Related