summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2016-05-25 07:26:32 +0200
committerLukas Rytz <lukas.rytz@typesafe.com>2016-05-25 07:26:32 +0200
commit734c5ad3df5602d52a4be02eaef773d347f742df (patch)
tree889e3a4f49104559fb46b553d2b6f59c68ca4ce2 /src
parenteaefb10e26724f93a447c3b4df3cc073c8465d39 (diff)
parent5fd8483d53521f17c1a697fdf419d35f1cacfac6 (diff)
downloadscala-734c5ad3df5602d52a4be02eaef773d347f742df.tar.gz
scala-734c5ad3df5602d52a4be02eaef773d347f742df.tar.bz2
scala-734c5ad3df5602d52a4be02eaef773d347f742df.zip
Merge pull request #5052 from kilotaras/topic/map-applyOrElse
Added applyOrElse to MapLike
Diffstat (limited to 'src')
-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.
*/