From: Rob Biedenharn Date: 2011-04-04T21:42:32+09:00 Subject: Re: Splitting each_cons? On Apr 3, 2011, at 5:07 PM, Simon Harrison wrote: > Thanks guys. More options to try and remember! That's one of the > things > that bugs me a bit about Ruby. TMTOWTDI. > > each |film| film.first, film.last > each |film| film.join > each |label, volume| ... > > My brain would like: if you have an array with subarrays acting as > key, > value pairs, do this to access them. You should look at the Array#assoc method that lets you do exactly this. http://www.ruby-doc.org/core/classes/Array.html#M000269 -Rob P.S. Sorry if this was mentioned already, I know I'm jumping into the middle of this conversation. > But, how am I to to decide which is > the "best" option from the above? I suppose it depends on the > situation. > It becomes hard when every situation has multiple solutions and each > solution may effect what to do next; which has multipe solutions etc. > > Still, I've tried Perl, Python, Lisp, C, C++, C#, Java, VB and > probably > more, but Ruby seems to make sense more than all of these. At least > I've > achieved something, eh? > > -- > Posted via http://www.ruby-forum.com/. > Rob Biedenharn Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ rab@GaslightSoftware.com http://GaslightSoftware.com/