Skip to content

Instantly share code, notes, and snippets.

@ygit
Created April 4, 2019 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ygit/ebeb396774bac8b4c6802e891b70201e to your computer and use it in GitHub Desktop.
Save ygit/ebeb396774bac8b4c6802e891b70201e to your computer and use it in GitHub Desktop.
Random Int Generator Swift Extension
extension Int {
var arc4random: Int {
if self > 0 {
return Int(arc4random_uniform(UInt32(self)))
} else if self < 0 {
return -Int(arc4random_uniform(UInt32(abs(self))))
} else {
return 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment