From 191891963c02e82c729cfcde6273474841b620df Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Thu, 21 Nov 2013 11:08:19 +0400 Subject: [PATCH] Fixed warning with 'orEmpty' function --- libraries/stdlib/src/kotlin/JUtil.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/stdlib/src/kotlin/JUtil.kt b/libraries/stdlib/src/kotlin/JUtil.kt index 0b5c3176933..4aaa658fdfa 100644 --- a/libraries/stdlib/src/kotlin/JUtil.kt +++ b/libraries/stdlib/src/kotlin/JUtil.kt @@ -24,8 +24,7 @@ val Collection<*>.notEmpty : Boolean get() = isNotEmpty() /** Returns the Collection if its not null otherwise it returns the empty list */ -public fun Collection?.orEmpty() : Collection - = if (this != null) this else Collections.emptyList() as Collection +public fun Collection?.orEmpty() : Collection = this ?: Collections.emptyList() /** TODO these functions don't work when they generate the Array versions when they are in JLIterables */ @@ -37,8 +36,7 @@ public fun > Iterable.toSortedList(comparator: java.util.Com // List APIs /** Returns the List if its not null otherwise returns the empty list */ -public fun List?.orEmpty() : List - = if (this != null) this else Collections.emptyList() as List +public fun List?.orEmpty() : List = this ?: Collections.emptyList() /** TODO figure out necessary variance/generics ninja stuff... :)