> Actually I use a lot of Applescript style naming, though admittedly I can be 
> a bit inconsistent about it. For example, I like using eachFoo as a name for 
> a loop variable like so:
> 
>       for eachIndex in 1 ..< 100 { … }
> 
> Which can read nicely as natural language, but since I don’t use eachFoo 
> anywhere else, helps to avoid name collisions. If eachFoo is optional, then I 
> might unwrap the value into theFoo instead like-so:
> 
>       let theValues:[Int?] = []
>       for eachValue in theValues {
>               if let theValue = eachValue { /* Do some stuff */ }
>               else { /* Do some other stuff */ }
>       }

Interesting! :-) I should explore this, sounds fun in some cases.

I typically just use the bare word:

for value in values {
  if let value = value {
    foo(value)
  }
}

...but sometimes that clashes with an argument or field, and yours could be a 
good convention to resolve those cases.

A.

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to