This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let double = Double.random(in: -1.2...4.5) | |
let integer = Int.random(in: .min ... .max) | |
let unsignedInteger = UInt.random(in: 4...9) | |
let bool = Bool.random() | |
var generator = SystemRandomNumberGenerator() | |
let double2 = Double.random(in: 1.0..<4.2, using: &generator) | |
let array = ["Cat", "Cow", "Dog", "Sheep"] | |
if let element = array.randomElement() { | |
print(element) // e.g Dog | |
} | |
let shuffled = array.shuffled() | |
print(array, shuffled) // e.g ["Cat", "Cow", "Dog", "Sheep"] ["Dog", "Cow", "Sheep", "Cat"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment