Tag: 可变性

Swift使方法参数可变?

我怎样才能处理这个错误,而不创build额外的variables? func reduceToZero(x:Int) -> Int { while (x != 0) { x = x-1 // ERROR: cannot assign to 'let' value 'x' } return x } 我不想创build额外的variables来存储x的值。 是否有可能做我想要的?