INNER CODE UNIT · Swift

group

peripheryapp/periphery · Sources/Extensions/Array+Extension.swift:5

    func group<U: Hashable>(by transform: (Element) -> U) -> [U: [Element]] {
        reduce([:]) { dictionary, element in
            var dictionary = dictionary
            let key = transform(element)
            dictionary[key] = (dictionary[key] ?? []) + [element]
            return dictionary
        }
    }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…