Answers for "create random words swift"

1

random string swift

func randomString(of length: Int) -> String {
    let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    var s = ""
    for _ in 0 ..< length {
        s.append(letters.randomElement()!)
    }
    return s
}
Posted by: Guest on June-13-2020
6

swift generate random number

let randomInt = Int.random(in: 0..<6)
let randomDouble = Double.random(in: 2.71828...3.14159)
let randomBool = Bool.random()
Posted by: Guest on March-02-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language