I was reading the memory safety chapter in swift, and wanted to try this exemple :
var stepSize = 1
func increment(_ number: inout Int) {
number += stepSize
}
increment(&stepSize)
Event if it says that there is an error because of the conflicting access to the stepsize
variable (long term access in writing), it actually compiles and give me the right answer (ie 2).
Can anyone give an exemple of when long term access to a variable will result in an error ? I can't come with one.
edit:
I tested with a playground on Xcode 9.2