Thanks guys - I'm going to look at cleaning this up a bit. The 120
stems from the fact that there will always be exactly 120 teams (well
until the year 2012-2013) when South Alabama joins Div. 1.
My initial problem started when I didn't understand how to organize two
arrays into a hash of hashes and sort through them. The example given
used 120.times and I kind of inherited that mechanic going forward. In
hindsight, I knew it felt wrong but I just didn't get to the cleanup.
My focus problem with ruby iteration is understanding .each and
.each_with_index when handling array of arrays.
When querying data from a model it's stored into an array. When using
each you iterate through each row and the value passed to the block is
used for iterating through that row.
example = model.find(:all)
example.each do |row|
puts "id = #{row.id} and name = #{row.name}"
end
Correct? Seems simple enough.. however,..
What if I have an array of arrays:
First glance I would think I would use each_with_index to handle an
array of arrays. But, I believe I've been having trouble using that
because by using times in the way that I have been some arrays are
populated and starting with 1 versus 0.
I'll try cleaning up the code and post a cleanup version for you to look
at to see if I'm progressing correctly.
Thanks again.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---