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
Was this helpful?