Why does this code count 6 elements, as 9 ("wrong") in swift playground.
var stringArray = ["1", "2", "3", "4", "5", "6"]
for var i = 0; i < 3; i++ {
stringArray.append("Paragraph" + "\(i)")
}
func concat (array: [String]) -> String {
let count = UInt32(stringArray.count) ** --> =9 **
let randomNumberOne = Int(arc4random_uniform(count))
let randomNumberTwo = Int(arc4random_uniform(count))
let randomNumberThree = Int(arc4random_uniform(count))
let concatString = array[randomNumberOne] + array[randomNumberTwo] + array[randomNumberThree]
return concatString
}
let finalString = concat(stringArray)
...but count this code as 6 (correct)
var stringArray = ["1", "2", "3", "4", "5", "6"] ** --> =6 **
let count = UInt32(stringArray.count)
Does it have something to do with 64 vs 32 bit? I have Xcode Version 6.0 (6A313).