Created
June 26, 2018 00:18
-
-
Save aybekckaya/b7f776f5e61da04dbabb4f409265c857 to your computer and use it in GitHub Desktop.
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
extension Int { | |
static func randomNumber(min:Int , max:Int)->Int { | |
var minimum = min | |
var maximum = max | |
if minimum < 0 { minimum = 0 } | |
if maximum < 0 { maximum = 0 } | |
if minimum == maximum { return minimum } | |
else if minimum > maximum { return randomNumber(min:maximum , max:minimum) } | |
return minimum + Int(arc4random())%(maximum - minimum) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment