I have an array of objects that I want to count and transform. For instance:
[#<User id:1, count:0>, #<User id:2, count:0>, #<User id:2, count:0>, #<User id:3, count:0>, #<User id:1, count:0>, #<User id:1, count:0>]
would become:
[#<User id:1, count:3>, #<User id:2, count:2>, #<User id:3, count:1>]
The transformation is what confuses me, since a ‘map’, goes straight through, but this would be recursive.
1 Answer