Created
April 4, 2019 15:24
-
-
Save ygit/ebeb396774bac8b4c6802e891b70201e to your computer and use it in GitHub Desktop.
Random Int Generator Swift Extension
This file contains hidden or 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
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