As dasblinkenlight mentioned, the solution is to simply move the increment so that after you index the array.
, , postfix. ++index, index += 1 .
, . , , .
++ :
//++ declared as postfix operator before this.
func ++ (inout num: Int) -> Int {
let temp = num
num = num + 1
return temp
}
+= , :
func += (inout lhs: Int, rhs: Int) {
lhs = lhs + rhs
}
, ++ Int, , , += void ( ), , , Int .
source
share