Skip to content

Instantly share code, notes, and snippets.

@vjosullivan
Created August 26, 2016 09:54
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 vjosullivan/7b6f0debbd181f38903fba814632b778 to your computer and use it in GitHub Desktop.
Save vjosullivan/7b6f0debbd181f38903fba814632b778 to your computer and use it in GitHub Desktop.
Swift 3. Creates an array of n integers with random values in the range 0..<max. As written below, the code will generates 10 integers in the range 0..<100.
let testData = { (n: Int, max: UInt32) -> [Int] in
var array = [Int]()
for i in 0..<n {
array.append(Int(arc4random_uniform(max)))
}
return array
}(10, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment