Skip to content

Instantly share code, notes, and snippets.

@hansott
Last active August 29, 2015 14:09
Show Gist options
  • Save hansott/a4f703ba801754aa964d to your computer and use it in GitHub Desktop.
Save hansott/a4f703ba801754aa964d to your computer and use it in GitHub Desktop.
Generate random number from min - max
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