From 9c7992abbbaed75d90c3b4a3e8bf1f95c1f2a8b8 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sat, 20 Jun 2015 00:13:52 +0300 Subject: [PATCH] Use getOrElse in MapVal.get --- libraries/stdlib/src/kotlin/properties/Delegation.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libraries/stdlib/src/kotlin/properties/Delegation.kt b/libraries/stdlib/src/kotlin/properties/Delegation.kt index 9fac18e408a..1d6831379e2 100644 --- a/libraries/stdlib/src/kotlin/properties/Delegation.kt +++ b/libraries/stdlib/src/kotlin/properties/Delegation.kt @@ -208,11 +208,7 @@ public abstract class MapVal() : ReadOnlyProperty { public override fun get(thisRef: T, property: PropertyMetadata) : V { val map = map(thisRef) val key = key(property) - if (!map.containsKey(key)) { - return default(thisRef, property) - } - - return map[key] as V + return map.getOrElse(key, { default(thisRef, property) }) as V } }