Created
April 21, 2018 21:06
-
-
Save damuellen/5979128a88d0650106e9b4d637c6e002 to your computer and use it in GitHub Desktop.
StrideOperator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator .. : StrideFormationPrecedence | |
precedencegroup StrideFormationPrecedence { | |
lowerThan: RangeFormationPrecedence | |
} | |
func .. <T: Strideable>(left: Range<T>, right: T.Stride) -> StrideTo<T> { | |
return stride(from: left.lowerBound, to: left.upperBound, by: right) | |
} | |
func .. <T: Strideable>(left: ClosedRange<T>, right: T.Stride) -> StrideThrough<T> { | |
return stride(from: left.lowerBound, through: left.upperBound, by: right) | |
} | |
0...10..2 // {from 0, through 10, by 2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment