Created
April 17, 2017 09:04
-
-
Save Marcocanc/b86290615507c66be8c8e916a65444e3 to your computer and use it in GitHub Desktop.
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 { | |
public subscript(safe index: Index) -> Optional<Iterator.Element> { | |
guard self.startIndex..<self.endIndex ~= index else { return nil } | |
return self[index] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment