RosettaCodeData/Task/Associative-array-Creation/Scala/associative-array-creation-1.scala

7 lines
222 B
Scala
Raw Permalink Normal View History

2013-04-10 14:58:50 -07:00
// immutable maps
var map = Map(1 -> 2, 3 -> 4, 5 -> 6)
map(3) // 4
map = map + (44 -> 99) // maps are immutable, so we have to assign the result of adding elements
map.isDefinedAt(33) // false
map.isDefinedAt(44) // true