Core concept

List(1, 2, 3, 4).groupBy(_ % 2)  // Map(1 -> List(1, 3), 0 -> List(2, 4))
Advertisement

How it works

groupBy materializes fully. Large collections care.

Advertisement

Trade-offs + gotchas

Data aggregation. Bucketing.