From 617c3624a07721b22752c5081ce2b2ae74ea4443 Mon Sep 17 00:00:00 2001 From: Qaz Cetelic <51381523+QazCetelic@users.noreply.github.com> Date: Mon, 11 Oct 2021 09:25:53 +0200 Subject: [PATCH] Use ifEmpty --- src/commonMain/kotlin/ParseToSemver.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/ParseToSemver.kt b/src/commonMain/kotlin/ParseToSemver.kt index ce6d72d..82beb87 100644 --- a/src/commonMain/kotlin/ParseToSemver.kt +++ b/src/commonMain/kotlin/ParseToSemver.kt @@ -13,13 +13,11 @@ fun String.toSemVerOrNull(patchRequired: Boolean = false): SemVer? { patch = matches[3].toIntOrNull() ?: if (patchRequired) return null else 0, preRelease = matches[4].let { // Sets it to null if the string is empty - if (it.isEmpty()) null - else it + it.ifEmpty { null } }, buildMetadata = matches[5].let { // Sets it to null if the string is empty - if (it.isEmpty()) null - else it + it.ifEmpty { null } }, ) }