2009-01-06 65 views

回答

1

如果沒有真正查看細節,我不確定您需要Ruby中的模塊。迭代器和塊在那裏做你想做的事情。

+0

編輯發佈一個例子或一個例子的鏈接偶然? – dreftymac 2009-01-07 00:12:20

+0

檢查Gaius的答案,它有更多的細節:) – Keltia 2009-01-07 09:19:34

2

Ruby的Enumerable做你想要的一切,我想。 「...並返回由此類評估結果組成的列表」表示您想要Enumerable#map。我第一次會是這樣的:

[ {...}, {...}, {...}, ... ].map do |hash| 
    hash.something 
    do_other_stuff_with(hash) 
    hash     # important to have as last line b/c of how #map works 
end 
相關問題