seq.grouped(by:)

๐Ÿ‘‰ replit

// โญ๏ธ seq.grouped(by:)
extension Sequence {
    public func grouped<Key>(
        by keyForValue: (Element) -> Key
    ) -> [Key: [Element]] 
    {
        return Dictionary(grouping: self, by: keyForValue)
    }
}

Last updated