Earlier quoted context omitted.
Feels backwards to me, at least as a gut feel. groceriesByDepartment.mapValues { items in items.count } vs e.g. Ruby (or at least close, it has been a while): groceriesByDepartment.map { |item| item.count } The "in" makes it feel like you're calling "items.count" on...? and then getting the "items" from it (since it sorta implies that items are in items.count, which seems like nonsense). E.g. this reads more naturall…
I prefer Ruby's syntax too, but Swift also has a shorthand version which is, IMO, usually nicer. groceriesByDepartment.mapValues { $0.count }
stuff like this always makes me miss Ruby's even-shorter-hand version though :)
groceriesByDepartment.mapValues(&:count) # not ruby, but meh