> On Apr 6, 2016, at 12:43 PM, Dave Abrahams <dabrah...@apple.com> wrote:
> 
> 
> on Wed Apr 06 2016, Erica Sadun <erica-AT-ericasadun.com> wrote:
> 
>>    On Apr 6, 2016, at 12:16 PM, Dave Abrahams via swift-evolution
>>    <swift-evolution@swift.org> wrote:
>>    (0..<199).striding(by: -2)
>> 
>>    are even or odd.
>> 
>> (0..<199).striding(by: -2): 0..<199 == 0...198 Even
>> (1..<199).striding(by: -2): 1..<199 == 1...198 Even
> 
> I understand the logic that got you there, but I find it incredibly
> counter-intuitive that striding by 2s over a range with odd endpoints
> should produce even numbers... I can't imagine any way I'd be convinced
> that was a good idea.

Guidance:

When using odd integer literals to produce an even number sequence,
prefer the `...` operator to the `..<` operator and change your ending
literal to an even number.

-- E


> 
>> (0..<198).striding(by: -2): 1..<198 == 0...197 Odd
>> (1..<198).striding(by: -2): 1..<198 == 1...197 Odd
>> 
>> -- E
>> 
> 
> -- 
> Dave

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to