I'm trying to use the two following methods to recursively traverse arrays of arrays until the bottom and then come back up with the match results.
You know how in a tennis tournament they start with 32 matches and pair by pair the winner moves ahead, and at the end there's only one winner? That's what I want to replicate in Ruby.
I created a
tournament = [
[["one", "two"],["three", "four"]],
[["five", "six"],["seven", "eight"]]
[[["one", "two"], ["three", "four"]], [["five", "six"], ["seven", "eight"]]]
Looks like you want
each, and, as a commenter above notes, you didn't call
winner in the above code.
When you call:
that method actually returns the tournament, which is thus what
What you want is to replace it with
which returns a new array consisting of calling "winner" on each element of tournament.