On Wed, Jun 8, 2016 at 1:38 AM, Haravikk via swift-evolution <
swift-evolution@swift.org> wrote:

> I’m not sure I agree that this is confusing, a little extra to learn for
> new programmers perhaps but I think it’s fairly intuitive:
>
> while let value = foo.next() where someCondition(value) { … }
>
> This reads to me as “repeat the following block until this fails to be
> true”, the conditional binding in this case fails to be true if
> someCondition(value) isn’t true, so the loop ends. I think the key thing
> here is that the where clause is for the conditional binding and not the
> loop itself, so in this respect it behaves exactly like an if or guard
> statement.
>

So, I think it might be much clearer if, similarly to how there's a
discussion about unifying "where" vs. "comma" conditions in guard/if, we
could do the same here.

    while let value = foo.next(), let something = value.property, something
== 4 { ... }

(Apologies if this has been said; I haven't followed the whole thread
closely.)
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to