Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个对象数组:
[ obj1, obj2, obj3 ...... objn ]
其中每个对象都有一个属性,比如说A。
A
如何将此数组分解为多个数组,每个数组包含具有相同值的对象A?什么是最干净的实现?
[ obj1, obj2, obj3 ...... objn ].group_by(&:A).values