Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created July 9, 2020 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cardoso/282b99243f4d1a1425b8103458dd5dae to your computer and use it in GitHub Desktop.
Save cardoso/282b99243f4d1a1425b8103458dd5dae to your computer and use it in GitHub Desktop.
extension String {
static func random(length: Int = 10) -> String {
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
return String((0..<length).map{ _ in letters.randomElement()! })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment