[swift-evolution] Bls: Range that goes both ways

Jeremy Pereira jeremy.j.pereira at googlemail.com
Wed Sep 21 10:59:51 CDT 2016

> On 21 Sep 2016, at 11:44, Mr Bee via swift-evolution <swift-evolution at swift.org> wrote:
> But after I thought about it again, I think half-opened range doesn't really make any senses. The ..< operator (and my proposed ..> operator) should be removed. Or we have to accept the consequences that we also need the other accompanying operators. The … operator with optional `step` attribute that is able to go both ways is more important that half-opened range operator. 

This came up before on the list from whence I get the link


which justifies both why numbering starts at 0 and why the ..< operator is the most useful one. Th tl;dr version is that in a..< b you can find out how many integers are in the range with a - b and easily specify an empty range. With a … b you have to do a - b + 1 which is ugly and it is also problematic if you want to specify an empty range.

More information about the swift-evolution mailing list