From 3dc68a7b8b31721a3bb4cd5026fc3e581ad838b8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 2 Sep 2021 14:09:34 +0600 Subject: [PATCH] small addition to joinTo --- .../dev/inmo/micro_utils/common/JoinTo.kt | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/JoinTo.kt b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/JoinTo.kt index ddff9db3da7..760c55f9219 100644 --- a/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/JoinTo.kt +++ b/common/src/commonMain/kotlin/dev/inmo/micro_utils/common/JoinTo.kt @@ -2,8 +2,8 @@ package dev.inmo.micro_utils.common inline fun Iterable.joinTo( crossinline separatorFun: (I) -> R?, - prefix: R?, - postfix: R?, + prefix: R? = null, + postfix: R? = null, crossinline transform: (I) -> R? ): List { val result = mutableListOf() @@ -26,12 +26,26 @@ inline fun Iterable.joinTo( } inline fun Iterable.joinTo( - separator: R?, - prefix: R?, - postfix: R?, + separator: R? = null, + prefix: R? = null, + postfix: R? = null, crossinline transform: (I) -> R? ): List = joinTo({ separator }, prefix, postfix, transform) +inline fun Iterable.joinTo( + crossinline separatorFun: (I) -> I?, + prefix: I? = null, + postfix: I? = null, + crossinline transform: (I) -> I? +): List = joinTo(separatorFun, prefix, postfix, transform) + +inline fun Iterable.joinTo( + separator: I?, + prefix: I? = null, + postfix: I? = null, + crossinline transform: (I) -> I? +): List = joinTo({ separator }, prefix, postfix, transform) + inline fun Array.joinTo( crossinline separatorFun: (I) -> R?, prefix: R?, @@ -40,8 +54,8 @@ inline fun Array.joinTo( ): Array = asIterable().joinTo(separatorFun, prefix, postfix, transform).toTypedArray() inline fun Array.joinTo( - separator: R?, - prefix: R?, - postfix: R?, + separator: R? = null, + prefix: R? = null, + postfix: R? = null, crossinline transform: (I) -> R? ): Array = asIterable().joinTo(separator, prefix, postfix, transform).toTypedArray()