Created
June 24, 2016 16:48
-
-
Save InsertNetan/e7e93f1161a587af930cacc062d65076 to your computer and use it in GitHub Desktop.
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 { | |
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