Swift -- for 循环 Unary operator '++' cannot be applied to an operand of type '@lvalue Int'

for var i = 0; i < segmentArray!.count; i++ {
                
}
报错  Unary operator '++' cannot be applied to an operand of type '@lvalue Int’

替代方案

for i in 0..<self.segmentArray!.count {
    print("--->", i)
}

// 递增
for i in 0 ..< self.segmentArray!.count {              
}
            
// 递减
for i in (0 ..< self.segmentArray!.count).reversed() {          
}
            
// NON-SEQUENTIAL INDEXING     Using where
for i in (0 ..< self.segmentArray!.count) where i % 2 == 0 {            
}