I need to populate an Array (already declared and initialized) using a for loop in order to create a determinate amount of items.
I ended up with the following code:
func createValues() -> Array<Int> {
let usableRange:Range = 6..<11;
var arrayOfValues: Array<Int>=[]; //Array declared and initialized
for i in 0..<10 {
arrayOfValues.append(random(usableRange));
print(arrayOfValues[i]);
}
return arrayOfValues;
}
this code does what I expect it to do just fine. However, as soon as I comment out the line
print(arrayOfValues[i]);
Xcode throws the following warning:
Immutable value 'i' was never used; consider replacing with '_' or removing it
If I accept the suggestion the code works, but not as fine as it did before.
I'm just transitioning from Obj-C to Swift and I don't really know what the proper way to do this should be. Any help would be appreciated. Thanks in advance.
P.S. I'm aware that I don't need semicolons anymore, but old habits die hard, I guess...