Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created July 27, 2020 20:04
Show Gist options
  • Save cardoso/5c5ff07dc4534a7d4fba5b14a682037c to your computer and use it in GitHub Desktop.
Save cardoso/5c5ff07dc4534a7d4fba5b14a682037c 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