How to iterate multiple enumerables in ruby?
- by steenslag
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"