Contents

grouped(by:transform:)

Creates a grouping of rows that the method selects by choosing unique values the transform closure creates with elements of a column you select by name.

Declaration

func grouped<InputKey, GroupingKey>(by columnName: String, transform: (InputKey?) -> GroupingKey?) -> RowGrouping<GroupingKey> where GroupingKey : Hashable

Parameters

  • columnName:

    The name of a column.

  • transform:

    A closure that transforms a column’s elements into a hashable type.

Return Value

A collection of groups.

Discussion

Create groupings that group rows by:

  • Telephone area codes

  • The first letter of a person’s last name

  • A date’s year or quarter

  • Number ranges

See Also

Creating a Row Grouping by a Column