Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Last active October 23, 2018 13:24
Show Gist options
  • Save EmmanuelGuther/f9839ef24374ad23a01e040fc1da55e7 to your computer and use it in GitHub Desktop.
Save EmmanuelGuther/f9839ef24374ad23a01e040fc1da55e7 to your computer and use it in GitHub Desktop.
/** USAGE -> ('a'..'z').randomString(6) */
fun ClosedRange<Char>.randomString(lenght: Int) =
(1..lenght)
.map { (Random().nextInt(endInclusive.toInt() - start.toInt()) + start.toInt()).toChar() }
.joinToString("")
editTextRegisterStepThreeUserName.setText(('a'..'z').randomString(6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment