Skip to content

Commit a136167

Browse files
committed
Fix typos, add scala> prompt in example
1 parent 5804e4d commit a136167

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

overviews/collections/maps.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Mutable maps support in addition the operations summarized in the following tabl
7474
| **Cloning:** | |
7575
| `ms.clone` |Returns a new mutable map with the same mappings as `ms`.|
7676

77-
The addition and removal operations for maps mirror those for sets. As is the for sets, mutable maps also support the non-destructive addition operations `+`, `-`, and `updated`, but they are used less frequently because they involve a copying of the mutable map. Instead, a mutable map `m` is usually updated "in place", using the two variants `m(key) = value` or `m += (key -> value)`. There are is also the variant `m put (key, value)`, which returns an `Option` value that contains the value previously associated with `key`, or `None` if the `key` did not exist in the map before.
77+
The addition and removal operations for maps mirror those for sets. Like sets, mutable maps also support the non-destructive addition operations `+`, `-`, and `updated`, but they are used less frequently because they involve a copying of the mutable map. Instead, a mutable map `m` is usually updated "in place", using the two variants `m(key) = value` or `m += (key -> value)`. There is also the variant `m put (key, value)`, which returns an `Option` value that contains the value previously associated with `key`, or `None` if the `key` did not exist in the map before.
7878

7979
The `getOrElseUpdate` is useful for accessing maps that act as caches. Say you have an expensive computation triggered by invoking a function `f`:
8080

@@ -85,7 +85,7 @@ The `getOrElseUpdate` is useful for accessing maps that act as caches. Say you h
8585

8686
Assume further that `f` has no side-effects, so invoking it again with the same argument will always yield the same result. In that case you could save time by storing previously computed bindings of argument and results of `f` in a map and only computing the result of `f` if a result of an argument was not found there. One could say the map is a _cache_ for the computations of the function `f`.
8787

88-
val cache = collection.mutable.Map[String, String]()
88+
scala> val cache = collection.mutable.Map[String, String]()
8989
cache: scala.collection.mutable.Map[String,String] = Map()
9090

9191
You can now create a more efficient caching version of the `f` function:

0 commit comments

Comments
 (0)