chunked(on:)

Returns a collection of subsequences of this collection, chunked by grouping elements that project to equal values.

Chunked.swift:492
func chunked<Subject>(on projection: (Element) throws -> Subject) rethrows -> [(Subject, SubSequence)] where Subject : Equatable

Parameters

projection

A closure that takes an element in the collection and returns an Equatable value that can be used to determine if adjacent elements belong in the same group.