diceware: switch to buildString
lambda
This commit is contained in:
parent
0830499c6c
commit
95075bd1d0
1 changed files with 5 additions and 8 deletions
|
@ -23,15 +23,12 @@ constructor(
|
|||
|
||||
/** Generates a passphrase with [wordCount] words. */
|
||||
public fun generatePassphrase(wordCount: Int, separator: Char): String {
|
||||
return StringBuilder()
|
||||
.apply {
|
||||
repeat(wordCount) { idx ->
|
||||
append(wordMap[die.rollMultiple(DIGITS)])
|
||||
if (idx < wordCount - 1) append(separator)
|
||||
}
|
||||
return buildString {
|
||||
repeat(wordCount) { idx ->
|
||||
append(wordMap[die.rollMultiple(DIGITS)])
|
||||
if (idx < wordCount - 1) append(separator)
|
||||
}
|
||||
.toString()
|
||||
.trimEnd()
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
|
Loading…
Reference in a new issue