Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created June 10, 2020 02: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/7dbaa88064539d43871e84bf4b154c1f to your computer and use it in GitHub Desktop.
Save cardoso/7dbaa88064539d43871e84bf4b154c1f to your computer and use it in GitHub Desktop.
import Foundation
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