From 5fd8483d53521f17c1a697fdf419d35f1cacfac6 Mon Sep 17 00:00:00 2001 From: Taras Boiko Date: Sun, 20 Mar 2016 15:34:33 +0200 Subject: Added applyOrElse to MapLike This overrides default implementation from PartialFunction which used both contains(x) and get(x) with getOrElse. --- src/library/scala/collection/MapLike.scala | 4 ++++ 1 file changed, 4 insertions(+) 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. */ -- cgit v1.2.3