collection.lengthsOfElements

💾 程式: replitarrow-up-right

// ┌───────────────────────────────────────┐
// │    Collection + .lengthsOfElements    │
// └───────────────────────────────────────┘

extension Collection where Element: Collection {
    /// lengths (element.count) of elements
    /// ```
    ///   [[1,2], [1,2,3]].lengthsOfElements == [2, 3]
    /// ```
    public var lengthsOfElements: [Int] {
        return map { $0.count }
    }
}

Last updated