Pattern: Use of map
instead of flatMap
Issue: -
Prefer flatMap
over map
followed by reduce([], +)
.
Examples of correct code:
let foo = bar.map { $0.count }.reduce(0, +)
let foo = bar.flatMap { $0.array }
Examples of incorrect code:
let foo = ↓bar.map { $0.array }.reduce([], +)