This file contains 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 modalValue() -> Self.Element? { | |
// populate a dictionary of element vs count | |
var dict: [Self.Element : Int] = [:] | |
self.forEach { v in | |
if let count = dict[v] { | |
dict[v] = count + 1 | |
} else { |
OlderNewer