Created
December 12, 2016 00:53
-
-
Save iscrz/0e4fe89d3f8705674f1ccf69d7473a7d to your computer and use it in GitHub Desktop.
Swift 3 Array Wrap
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 Array { | |
subscript (wrap index: Int) -> Element { | |
return self[index - Int(floor(Double(index) / Double(count))) * count] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment