summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorTaras Boiko <kilotaras@gmail.com>2016-03-20 15:34:33 +0200
committerTaras Boiko <kilotaras@gmail.com>2016-03-20 15:34:33 +0200
commit5fd8483d53521f17c1a697fdf419d35f1cacfac6 (patch)
tree55495c7429d36c7f85d2b8ea45cd736c33e28e9f /src/library
parent99a82be91cbb85239f70508f6695c6b21fd3558c (diff)
downloadscala-5fd8483d53521f17c1a697fdf419d35f1cacfac6.tar.gz
scala-5fd8483d53521f17c1a697fdf419d35f1cacfac6.tar.bz2
scala-5fd8483d53521f17c1a697fdf419d35f1cacfac6.zip
Added applyOrElse to MapLike
This overrides default implementation from PartialFunction which used both contains(x) and get(x) with getOrElse.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/MapLike.scala4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala
index 4ac87b29a9..d4d85c43ec 100644
--- a/src/library/scala/collection/MapLike.scala
+++ b/src/library/scala/collection/MapLike.scala
@@ -158,6 +158,10 @@ self =>
*/
def isDefinedAt(key: A) = contains(key)
+ override /*PartialFunction*/
+ def applyOrElse[A1 <: A, B1 >: B](x: A1, default: A1 => B1): B1 =
+ getOrElse(x, default(x))
+
/** Collects all keys of this map in a set.
* @return a set containing all keys of this map.
*/