Created
July 20, 2016 08:56
-
-
Save Appletone/152729e2af2b9b722d14c4d466077cff to your computer and use it in GitHub Desktop.
Array Next Element
This file contains hidden or 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 where Element: Hashable { | |
func after(item: Element) -> Element? { | |
if let index = self.indexOf(item) where index + 1 < self.count { | |
return self[index + 1] | |
} | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment