Back to the initial example, here’s a variant that shows a “non-mutable” 
pointer lying; try it in a playground.

```
func get(_ pointer: UnsafePointer<Int>, at index: Int) -> Int
{
  let mutator = UnsafeMutablePointer(mutating: pointer)
  mutator[index] += 1
  return pointer[index]
}

let constantArray = [Int](repeating: 0, count: 3)

print(constantArray)    // [0,0,0]

let mutated = get(constantArray, at: 2) // returns 1

print(constantArray) // [0,0,1] oops!
```

I’d argue that this case should also require an ampersand and a mutable array.

Cheers,
Guillaume Lessard

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to