Ruby on Rails Thursday, July 31, 2014

On Jul 31, 2014, at 10:00 AM, Eric Saupe <ericsaupe@gmail.com> wrote:

> I knew there would be a nice simpler Ruby way. I love the second solution, Rob. Below is the updated example.

One tiny note, this is purely a matter of style & taste, spelling it out vs concision, but I thought it might be good for your learning to understand that you could also use:

arrays = [[], [], []]

And, if you wanted a set of arrays that you access by string instead of int:

arrays = {'one' => [], 'two' => [], 'three' => []}
arrays['one'].push(42)
puts arrays['one'][0]

--
Scott Ribe
scott_ribe@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/921549A3-013A-42CC-81DC-C9D893BDDBE5%40elevated-dev.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment