- We have the option to select either Mutable or Immutable Map #90
- By default, Immutable set will be used if we do not Specificy the Mutuable Map package
- Package
- scala.collection.mutable
- scala.collection.immutable
/*
Immutable Map example #90
(Default Implementation)
*/
// '->' is a method that returns a Tuple of key & value
val m1 = Map( "math" -> "80", "english" -> "90")
val m2 = Map(("math", "80"), ("english", "90"))
m2("some") = "value"
/*
Mutable Map example #90
*/
import scala.collection.mutable
val m1 = mutable.Map()
val m1 = mutable.Map[String, String]()
m1("science") = "80"
m1("math") = "85"
m1
/*
HashMap example
*/
import scala.collection.immutable
val m1 = immutable.Map( "math" -> "80", "english" -> "90")