Skip to content

Instantly share code, notes, and snippets.

@InsertNetan
Created June 24, 2016 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InsertNetan/e7e93f1161a587af930cacc062d65076 to your computer and use it in GitHub Desktop.
Save InsertNetan/e7e93f1161a587af930cacc062d65076 to your computer and use it in GitHub Desktop.
extension Array where Element: Hashable {
var occurrencesCount :[Element : Int] {
var map = [Element : Int]()
forEach { element in
if let val = map[element]{
map[element] = val+1
} else {
map[element] = 1
}
}
return map
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment