Last active
August 29, 2015 14:09
-
-
Save hansott/a4f703ba801754aa964d to your computer and use it in GitHub Desktop.
Generate random number from min - max
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
func generateRandomIndex(#lower: Int , upper: Int) -> Int { | |
return lower + Int(arc4random_uniform(UInt32(upper - lower + 1))) | |
} | |
// Usage | |
var randomDice : Int = generateRandomIndex(lower: 1, upper: 6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment