Skip to content

Commit 2c2aa79

Browse files
committed
Add a note about keySet on mutable maps
1 parent 6760bd1 commit 2c2aa79

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/src/scala/collection/Map.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ transparent trait MapOps[K, +V, +CC[_, _] <: IterableOps[?, AnyConstr, ?], +C]
191191
* - To ensure an independent strict collection, use `m.keysIterator.toSet`
192192
* - To obtain a view on the keys, use `scala.collection.View.fromIteratorProvider(m.keysIterator)`
193193
*
194+
* Specifically, for mutable collections, it is **not** guaranteed that the set would reflect the changes made onto
195+
* the map, **nor** it is guaranteed that the set would _not_ reflect the changes. To guarantee either behavior,
196+
* obtain a strict collection or a view as above.
197+
*
194198
* @return a set representing the keys contained by this map
195199
*/
196200
def keySet: Set[K] =

0 commit comments

Comments
 (0)