> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/ios/swift/collections/collection/collection.lengthsofelements.md).

# collection.lengthsOfElements

{% tabs %}
{% tab title="🌀 Collection" %}
💾 程式： [replit](https://replit.com/@pegasusroe/Swift-Playground#Extenions/Collection+.swift)

````swift
// ┌───────────────────────────────────────┐
// │    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 }
    }
}
````

{% endtab %}

{% tab title="👥 相關" %}
\*
{% endtab %}
{% endtabs %}
