I strongly disagree with you. You can not "accidentally" do any thing as the
name of the variable used will be written. Now it is written "i" and is not
cleat what i is...
Adding "let" may help but only in case that it is not allowed to use the name
"i" in the same method. Having more that one variable with the same name in one
method is stupid and the language should prevent that at least.
On Tuesday, March 29, 2016 4:16 AM, Brent Royal-Gordon
<[email protected]> wrote:
> What is the value of i ??
0, because `for i` implicitly declares a new variable `i`. You could perhaps
argue that you should have to explicitly say `for let i`, but that seems
pointless because the `let` would always be necessary. (Well, unless you did a
`for case` or `for _`, but those are rare constructs.)
> My suggestion is to use the variable i in the loop instead of making hidden
> init of another "i" for the loop.
That seems like an extremely bad idea. What if the loop variable is a property
or global and you accidentally end up using it implicitly? That's *way* worse
than shadowing the outer variable.
--
Brent Royal-Gordon
Architechies
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution