[swift-evolution] [Draft]: Introducing a striding(by:) method on 3.0 ranges

davesweeris at mac.com davesweeris at mac.com
Sat Apr 9 13:51:23 CDT 2016


> On Apr 9, 2016, at 3:27 AM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> On Sat, Apr 9, 2016 at 5:44 AM, Wallacy via swift-evolution
> <swift-evolution at swift.org> wrote:
>> Just as note, i think the sintax should be:
>> 
>> 0...9
>> 0..<9
>> 0>..9
>> 0>.<9
>> 
>> Because the intention is produce a number bigger than 0 (start). So greater
>> than zero less than nine.
> 
> That's not typically how it's written in math. When x is between two
> values a and b, it's written a < x < b. The pointy end of the symbol
> faces the smaller value. Here, 0 is the smaller value, so the pointy
> end must face it, as in `0 <.. 9` and `0 <.< 9`.

Exactly. Up until just a few days ago, I would’ve agreed with Wallacy. I thought the range operators, “a … b” and “a ..< b”, were supposed to represent “[a b]” and “[a b)”. Once the topic came up here, I realized that they were intended to approximate the notation “a ≤ x ≤ b” and “a ≤ x < b”, which visually speaking makes a lot more sense to me. With that in mind, “a <.. b” and “a <.< b” are the correct ways to extend the notation. IMHO, anyway.

- Dave Sweeris


More information about the swift-evolution mailing list