我在 Ruby 中有一个数组,如下所示:
@arr = [ [2.1, pass],
[2.1, fail],
[2.1, pass],
[2.1, unknown],
[2.1, pass],
[3.0, pass],
[3.0, unknown],
[3.1, pass],
[3.1, fail] ]
我想对其应用某种散列或计算,以便我的输出应该是一个数组,如:
@result = [ [2.1, 3, 1, 1],
[3.0, 1, 0, 1],
[3.1, 1, 1, 0] ]
输出数组以这种格式显示结果 {version, no.of pass, no.of fail, no.of unknown}