I ended up here after following Set-only subscripts and not being convinced by Dave's argument that x[b] = y
implies that x[b].mutatingMethod()
may be called. I've had similar difficulties in grasping that a mutating method can reassign self
which I, ignoring the underlying practicalities, still consider a weird and very narrow use case.
and
But how is this still true with non-copyable types? Yes, foo
can be read but it can't be copied without a consume
operator, in which case it's no longer possible to reassign it since it's out of scope. Doing otherwise is essentially the same as a set-only property, no?