I want to generate a random number that can be between
-3...-8
and 3...8
I know I could find a roundabout way of doing this by first doing a random integer between 0 and 1 and then picking the range on that:
let zeroOrOne = CGFloat.random(in: 0...1)
if zeroOrOne == 0 {
randomNum = CGFloat.random(in: -3...-8)
} else {
randomNum = CGFloat.random(in: 3...8)
}
but I am wondering if there is a better way of doing this.