-
-
Save jasdev/7568288f7a7721bdadf95f022da44ece to your computer and use it in GitHub Desktop.
Collection.rotated(toStartAt:) approach.
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
extension Collection { | |
func rotated(toStartAt newStart: Index) -> AnyCollection<Element> { | |
self[newStart...] + self[..<newStart] // ❌ “Cannot convert return | |
// expression of type `SubSequence` to return type `AnyCollection<Element>`.” | |
// | |
// ❌ “Referencing operator function `+` on `RangeReplaceableCollection` | |
// requires that `SubSequence` conform to `RangeReplaceableCollection`.” | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment