It's already possible:
for d in stride(from: 0, to: 5, by: 0.3) {
}
Absolutely readable (despite all efforts to break it).
And I would passionately hate the special syntax for floating-point loops
in Swift.
It's already possible:
for d in stride(from: 0, to: 5, by: 0.3) {
}
Absolutely readable (despite all efforts to break it).
And I would passionately hate the special syntax for floating-point loops
in Swift.
Actually you cannot use the global stride function anymore.
extension Strideable {
- public func stride(to end: Self, by stride: Stride) -> StrideTo<Self>
}
+public func stride<T : Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T>
extension Strideable {
- public func stride(through end: Self, by stride: Stride) -> StrideThrough<Self>
}
+public func stride<T : Strideable>(from start: T, through end: T, by stride: T.Stride) -> StrideThrough<T>
On Mar 8, 2016, at 11:13 AM, Maximilian Hünenberger via swift-evolution <swift-evolution@swift.org> wrote:
I thought a method on "Range" which returns a stride would be easier to grasp:
for x in 0.stride(to: 0.5, by: 0.03) { ... }
// much faster to predict what is does even though it is less clear to a beginner
for x in (0 ... 0.5).by(0.03) { ... }- Maximilian
Am 08.03.2016 um 18:56 schrieb Антон Жилин <antonyzhilin@gmail.com>:
It's already possible:
for d in stride(from: 0, to: 5, by: 0.3) {
}Absolutely readable (despite all efforts to break it).
And I would passionately hate the special syntax for floating-point loops in Swift._______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
So long as I don't have to wear a scarlet semicolon for the rest of my life.
-- E
On Mar 8, 2016, at 11:19 AM, Maximilian Hünenberger <m.huenenberger@me.com> wrote:
Oh... Missed that change. But my point still stands :)
Best regards
- MaximilianAm 08.03.2016 um 19:15 schrieb Erica Sadun <erica@ericasadun.com <mailto:erica@ericasadun.com>>:
On Mar 8, 2016, at 11:13 AM, Maximilian Hünenberger via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
Actually you cannot use the global stride function anymore.
extension Strideable {
- public func stride(to end: Self, by stride: Stride) -> StrideTo<Self>
}
+public func stride<T : Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T>extension Strideable {
- public func stride(through end: Self, by stride: Stride) -> StrideThrough<Self>
}
+public func stride<T : Strideable>(from start: T, through end: T, by stride: T.Stride) -> StrideThrough<T>I thought a method on "Range" which returns a stride would be easier to grasp:
for x in 0.stride(to: 0.5, by: 0.03) { ... }
// much faster to predict what is does even though it is less clear to a beginner
for x in (0 ... 0.5).by(0.03) { ... }- Maximilian
Am 08.03.2016 um 18:56 schrieb Антон Жилин <antonyzhilin@gmail.com <mailto:antonyzhilin@gmail.com>>:
It's already possible:
for d in stride(from: 0, to: 5, by: 0.3) {
}Absolutely readable (despite all efforts to break it).
And I would passionately hate the special syntax for floating-point loops in Swift._______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution
Actually you cannot use the global stride function anymore.
It's coming back; never fear.
on Tue Mar 08 2016, Maximilian Hünenberger <swift-evolution@swift.org> wrote:
I thought a method on "Range" which returns a stride would be easier to grasp:
for x in 0.stride(to: 0.5, by: 0.03) { ... }
// much faster to predict what is does even though it is less clear to a beginner
for x in (0 ... 0.5).by(0.03) { ... }- Maximilian
Am 08.03.2016 um 18:56 schrieb Антон Жилин <antonyzhilin@gmail.com>:
It's already possible:
for d in stride(from: 0, to: 5, by: 0.3) {
}Absolutely readable (despite all efforts to break it).
And I would passionately hate the special syntax for floating-point loops in Swift._______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution
--
-Dave
Frankly I find the free function to be much more readable than either of these.
on Tue Mar 08 2016, Maximilian Hünenberger <swift-evolution@swift.org> wrote:
Actually you cannot use the global stride function anymore.
I thought a method on "Range" which returns a stride would be easier to grasp:for x in 0.stride(to: 0.5, by: 0.03) { ... }
// much faster to predict what is does even though it is less clear to a beginner
for x in (0 ... 0.5).by(0.03) { ... }
--
-Dave
I am really happy to welcome it back.
-- E
On Mar 8, 2016, at 5:33 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:
on Tue Mar 08 2016, Maximilian Hünenberger <swift-evolution@swift.org> wrote:
Actually you cannot use the global stride function anymore.
I thought a method on "Range" which returns a stride would be easier to grasp:for x in 0.stride(to: 0.5, by: 0.03) { ... }
// much faster to predict what is does even though it is less clear to a beginner
for x in (0 ... 0.5).by(0.03) { ... }Frankly I find the free function to be much more readable than either of these.
extension Strideable {
- public func stride(to end: Self, by stride: Stride) -> StrideTo<Self>
}
+public func stride<T : Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T>
extension Strideable {
- public func stride(through end: Self, by stride: Stride) -> StrideThrough<Self>
}
+public func stride<T : Strideable>(from start: T, through end: T, by stride: T.Stride) -> StrideThrough<T>
-- E, will repaste for cookies
On Mar 8, 2016, at 5:32 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:
on Tue Mar 08 2016, Maximilian Hünenberger <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
Actually you cannot use the global stride function anymore.
It's coming back; never fear.
Actually you cannot use the global stride function anymore.
I thought a method on "Range" which returns a stride would be easier to grasp:
for x in 0.stride(to: 0.5, by: 0.03) { ... }
// much faster to predict what is does even though it is less clear to a beginner
for x in (0 ... 0.5).by(0.03) { ... }
- Maximilian
Am 08.03.2016 um 18:56 schrieb Антон Жилин <antonyzhilin@gmail.com>:
It's already possible:
for d in stride(from: 0, to: 5, by: 0.3) {
}Absolutely readable (despite all efforts to break it).
And I would passionately hate the special syntax for floating-point loops in Swift.
Oh... Missed that change. But my point still stands :)
Best regards
- Maximilian
Am 08.03.2016 um 19:15 schrieb Erica Sadun <erica@ericasadun.com>:
On Mar 8, 2016, at 11:13 AM, Maximilian Hünenberger via swift-evolution <swift-evolution@swift.org> wrote:
Actually you cannot use the global stride function anymore.
extension Strideable {
- public func stride(to end: Self, by stride: Stride) -> StrideTo<Self>
}
+public func stride<T : Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T>extension Strideable {
- public func stride(through end: Self, by stride: Stride) -> StrideThrough<Self>
}
+public func stride<T : Strideable>(from start: T, through end: T, by stride: T.Stride) -> StrideThrough<T>I thought a method on "Range" which returns a stride would be easier to grasp:
for x in 0.stride(to: 0.5, by: 0.03) { ... }
// much faster to predict what is does even though it is less clear to a beginner
for x in (0 ... 0.5).by(0.03) { ... }- Maximilian
Am 08.03.2016 um 18:56 schrieb Антон Жилин <antonyzhilin@gmail.com>:
It's already possible:
for d in stride(from: 0, to: 5, by: 0.3) {
}Absolutely readable (despite all efforts to break it).
And I would passionately hate the special syntax for floating-point loops in Swift._______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution