我的阵营在铁轨中使用的常用习语如下:
def right_things(all_things, value) things = [] for thing in all_things things << thing if thing.attribute == value end return things end
我怎样才能让这更好/更快/更强?
谢谢
-C
def right_things(all_things, value) all_things.select{|x| x.attribute == value} end