diff options
author | Paul Phillips <paulp@improving.org> | 2009-08-21 18:18:39 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-08-21 18:18:39 +0000 |
commit | d0024b6e996e294f790972a67b3dd47e2b02dff2 (patch) | |
tree | 7d157c44d33a4b226dd167c5afe9d43657937d00 /src | |
parent | 7039772a3ae96fe79b1bbc5e55745a59080a5227 (diff) | |
download | scala-d0024b6e996e294f790972a67b3dd47e2b02dff2.tar.gz scala-d0024b6e996e294f790972a67b3dd47e2b02dff2.tar.bz2 scala-d0024b6e996e294f790972a67b3dd47e2b02dff2.zip |
Fix for the discovery that .get on a non-existe...
Fix for the discovery that .get on a non-existent Map key returns None,
even if a default value has been declared.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/immutable/Map.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala index 929d41bc99..5b3bbc91b4 100644 --- a/src/library/scala/collection/immutable/Map.scala +++ b/src/library/scala/collection/immutable/Map.scala @@ -47,7 +47,7 @@ object Map extends ImmutableMapFactory[Map] { class WithDefault[A, +B](underlying: Map[A, B], d: A => B) extends Map[A, B] { override def size = underlying.size - def get(key: A) = underlying.get(key) + def get(key: A) = underlying.get(key) orElse Some(default(key)) def iterator = underlying.iterator override def empty = new WithDefault(underlying.empty, d) override def updated[B1 >: B](key: A, value: B1): WithDefault[A, B1] = new WithDefault[A, B1](underlying.updated[B1](key, value), d) |