我正在使用如下所示的一组 OpenStruct 对象:
a=[<OpenStruct name="test1", x="6", id="1">,<OpenStruct name="test2", x="5", id="2"><OpenStruct name="test1", x="8", id="3">...]
我想对具有相同名称的 OpenStruct 对象进行分组,如下所示:
a=[<OpenStruct name="test1",x=["6","8"], id=["1","3"]>,<OpenStruct name="test2", x="5", id="2">]
我怎样才能做到这一点?