Creating an array in Swift that has random boolean values -


i working on function must create array of random boolean values , lost @ how make work inside function. on appreciated. sadly, confined rules names , how must see general structure must use, can't see how logically isn't woking.

func thirdfunction() { //var numoftrue = 0 //var numoffalse = 0 var sometrue = true  var randbools = [bool] ()  num in 1...10{     let random = arc4random_uniform(2)     print(random)     if (random == 0){         sometrue = false         randbools.append(sometrue)     } else {         randbools.append(sometrue)     } } print (randbools) } 

this works:

var array: [bool] = []  func randomizer() {     var bool: bool = false      num in 1...10 {         let random = arc4random_uniform(2)         if random == 0 {             bool = false         } else {             bool = true         }         array.append(bool)     }     print(array) } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -