Skip to content

Instantly share code, notes, and snippets.

@Appletone
Created July 20, 2016 08:56
Show Gist options
  • Save Appletone/152729e2af2b9b722d14c4d466077cff to your computer and use it in GitHub Desktop.
Save Appletone/152729e2af2b9b722d14c4d466077cff to your computer and use it in GitHub Desktop.
Array Next Element
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