Skip to content

Commit

Permalink
Fixed 'Random.string'
Browse files Browse the repository at this point in the history
  • Loading branch information
Elifarley Cruz committed Jan 2, 2020
1 parent c10da41 commit e3049b1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/src/main/kotlin/klib/base/StringKit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ val COMMON_CHARS = ALPHANUM_CHARS + ".- ".toList()
fun CharArray.concatToString() = String(this)

fun Random.string(len: Int = 10, chars: Array<Char> = 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
Expand Down

0 comments on commit e3049b1

Please sign in to comment.