Skip to content

Commit

Permalink
Use ifEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
QazCetelic committed Oct 11, 2021
1 parent 133f255 commit 617c362
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/commonMain/kotlin/ParseToSemver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
},
)
}
Expand Down

0 comments on commit 617c362

Please sign in to comment.