更新时间:2022-10-15 16:29:06
The &:age
means that the group_by
method should call the age
method on the items to get the group by data. This age
method is not defined on the items which are Hashes.
This should work:
array.group_by { |d| d[:age] }