[swift-evolution] Mutability inference
clattner at apple.com
Wed Feb 24 12:40:13 CST 2016
> On Feb 23, 2016, at 11:06 PM, Darko Damjanovic via swift-evolution <swift-evolution at swift.org> wrote:
> In the current Swift version the compiler is warning me if a variable is never written to and therefore should be a "let" constant. So now the compiler knows best if "let" or "var" should be applied. During writing code I experience repetitive hints about using "let" or "var" so why do I have to declare it all the time by myself if the compiler anyway knows best?
The problem with this approach is that you’re favoring writability of the code at the expense of readability/maintainability. The major win of having let and var in the code is that it expresses the intention of what is happening: when you see a “let x = …” you know that x will never be changed.
More information about the swift-evolution