How to iterate multiple enumerables in ruby?

Posted by steenslag on Stack Overflow See other posts from Stack Overflow or by steenslag
Published on 2010-04-10T22:25:28Z Indexed on 2010/04/10 22:33 UTC
Read the original article Hit count: 501

Filed under:
|

I know two arrays can be zipped and the result can be iterated with #each. But how do you do it with an unknown number of enumerables? Let's say

anand = &w(1-0 0.5-0.5 0.5-0.5 1.0)
carlsen = &w(0-1 0.5-0.5 0.5-0.5 1.0)
kramnik = &w(0.5-0.5 0.5-0.5 0.5-0.5 1.0)
players= [anand, carlsen, kramnik)
#something smart

players.each{|round|puts round} #first line should be  "1-0 0-1 0.5-0.5" 

© Stack Overflow or respective owner

Related posts about ruby

Related posts about enumerable