Can't the compiler detect this automatically (as it already does with a fixit)?
It sounds like the same discussion -- why
var and
let.
If it is a local variable, the compiler can automatically detect mutating usage and decide
var or
let automatically.
But what if it is a public property of a class in a library and may be used somewhere outside of your code?
I think there was once a discussion about this in forums.swift.org.
The main topic of
this thread is a little bit different than
why var and let, but includes some opinion for that.
In my opinion, it is important to declare it explicitly, to help compiler reduce compile time, and to help readers of your code understand the usage of the property.
Nearly the same may happen, when you are writing a method of a class in a library taking a closure.
Anyway, you should better visit forums.swift.org . If you are lucky enough, you may be able to hear some opinions from the core member of Swift Team.