Skip to content

Commit

Permalink
Stride should allow zero size.
Browse files Browse the repository at this point in the history
People expect strides to allow zero size - like any traditional `for` loop that would have just skipped.
Adding an additional condition just for that makes the code messier.

But moreover - Xcode itself expects it to allow `0` length stride.
As Xcode automatically converts old `for` loops to strides, it actually **breaks** code that may in some cases have zero-length strides.

ChartsOrg/Charts#931
  • Loading branch information
danielgindi committed Apr 10, 2016
1 parent c782dda commit 451fb44
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions stdlib/public/core/Stride.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public struct StrideTo<Element : Strideable> : Sequence, CustomReflectable {
}

internal init(_start: Element, end: Element, stride: Element.Stride) {
_precondition(stride != 0, "stride size must not be zero")
// Unreachable endpoints are allowed; they just make for an
// already-empty Sequence.
self._start = _start
Expand Down Expand Up @@ -218,7 +217,6 @@ public struct StrideThrough<
}

internal init(_start: Element, end: Element, stride: Element.Stride) {
_precondition(stride != 0, "stride size must not be zero")
self._start = _start
self._end = end
self._stride = stride
Expand Down

0 comments on commit 451fb44

Please sign in to comment.