From e3049b1bb358422c4f72c11255f1b42fde449c45 Mon Sep 17 00:00:00 2001 From: Elifarley Cruz Date: Thu, 2 Jan 2020 19:20:06 +0100 Subject: [PATCH] Fixed 'Random.string' --- base/src/main/kotlin/klib/base/StringKit.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/kotlin/klib/base/StringKit.kt b/base/src/main/kotlin/klib/base/StringKit.kt index c91d599..9170b09 100644 --- a/base/src/main/kotlin/klib/base/StringKit.kt +++ b/base/src/main/kotlin/klib/base/StringKit.kt @@ -10,7 +10,7 @@ val COMMON_CHARS = ALPHANUM_CHARS + ".- ".toList() fun CharArray.concatToString() = String(this) fun Random.string(len: Int = 10, chars: Array = ALPHANUM_CHARS.toTypedArray()) = CharArray(len) { - Random.nextInt(0, ALPHANUM_CHARS.size).let(ALPHANUM_CHARS::get) + Random.nextInt(0, chars.size).let(chars::get) }.concatToString() inline fun String.prefixWith(prefix: String?) = prefix?.plus(this) ?: this