diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-01-10 10:47:26 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-01-10 10:47:26 +0000 |
commit | 5b481bbff7e7cc68f241fb4dc3c6bddb66108940 (patch) | |
tree | 10274ea8070e1c8b9dab86356fe6d3c0615ceca3 | |
parent | bc55c7854ca96ced47aa05ca85039df28fe61509 (diff) | |
download | scala-5b481bbff7e7cc68f241fb4dc3c6bddb66108940.tar.gz scala-5b481bbff7e7cc68f241fb4dc3c6bddb66108940.tar.bz2 scala-5b481bbff7e7cc68f241fb4dc3c6bddb66108940.zip |
Added comments for #4008.
No review.
-rw-r--r-- | src/library/scala/collection/immutable/Map.scala | 16 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/Map.scala | 16 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala index d345b89057..db7e3c1e31 100644 --- a/src/library/scala/collection/immutable/Map.scala +++ b/src/library/scala/collection/immutable/Map.scala @@ -33,10 +33,22 @@ trait Map[A, +B] extends Iterable[(A, B)] override def toMap[T, U](implicit ev: (A, B) <:< (T, U)): immutable.Map[T, U] = self.asInstanceOf[immutable.Map[T, U]] - /** The same map with a given default function */ + /** The same map with a given default function. + * + * Invoking transformer methods (e.g. `map`) will not preserve the default value. + * + * @param d the function mapping keys to values, used for non-present keys + * @return a wrapper of the map with a default value + */ def withDefault[B1 >: B](d: A => B1): immutable.Map[A, B1] = new Map.WithDefault[A, B1](this, d) - /** The same map with a given default value */ + /** The same map with a given default value. + * + * Invoking transformer methods (e.g. `map`) will not preserve the default value. + * + * @param d the function mapping keys to values, used for non-present keys + * @return a wrapper of the map with a default value + */ def withDefaultValue[B1 >: B](d: B1): immutable.Map[A, B1] = new Map.WithDefault[A, B1](this, x => d) /** Add a key/value pair to this map. diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index 5df8594a16..e30a5a4f64 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -26,10 +26,22 @@ trait Map[A, B] override def empty: Map[A, B] = Map.empty - /** The same map with a given default function */ + /** The same map with a given default function. + * + * Invoking transformer methods (e.g. `map`) will not preserve the default value. + * + * @param d the function mapping keys to values, used for non-present keys + * @return a wrapper of the map with a default value + */ def withDefault(d: A => B): mutable.Map[A, B] = new Map.WithDefault[A, B](this, d) - /** The same map with a given default value */ + /** The same map with a given default value. + * + * Invoking transformer methods (e.g. `map`) will not preserve the default value. + * + * @param d the function mapping keys to values, used for non-present keys + * @return a wrapper of the map with a default value + */ def withDefaultValue(d: B): mutable.Map[A, B] = new Map.WithDefault[A, B](this, x => d) /** Return a read-only projection of this map. !!! or just use an (immutable) MapProxy? |