Random numbers


My notes on random numbers in swift

Random numbers

let randomBool = Bool.random()
let randomInt = Int.random(in: 1...6) //dice roll
let randomFloat = Float.random(in: 0...1)
let randomDouble = Double.random(in: 1..<100)

resources:

  • https://nemecek.be/blog/89/randomness-in-swift-comprehensive-overview