Skip to content

Instantly share code, notes, and snippets.

@srstanic
Created April 22, 2020 16:02
Show Gist options
  • Select an option

  • Save srstanic/a3b387e48cf868c620f55e6d5ecf0a36 to your computer and use it in GitHub Desktop.

Select an option

Save srstanic/a3b387e48cf868c620f55e6d5ecf0a36 to your computer and use it in GitHub Desktop.
extension Array where Element: Equatable {
func distinctUntilChanged() -> Self {
var resultArray = Self()
for element in self {
if resultArray.last != element {
resultArray.append(element)
}
}
return resultArray
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment