[swift-evolution] [Proposal] Add keyword "by" as syntactic sugar to streamline For-In-loop
Hans Huck
gutgedacht at gmx.de
Thu Apr 14 00:46:08 CDT 2016
> You may want to take a peek here: https://gist.github.com/erica/a51a981ee0352235204692affa959307
>
> -- E
>
Thanks for the link, Erica, very informative. The striding(by:) method combined with the (as of yet) non-canonical range types looks great; it also tackles half the problem, since it makes the use of reverse() no longer required in For-loops.
However, my main point remains unresolved, because
for i in (1...10).striding(by: -3)
is simply not as concise, readable, intuitive or elegant as
for i in 1...10 by -3
The "by" keyword is specifically meant to be syntactic sugar for the For-In-loop, and, as Vladimir pointed out, can easily be mapped onto the new striding() construct internally.
-- Hans
More information about the swift-evolution
mailing list