I am trying to get this going where i have this build array and then I have an array of hashes named after the items in the build. Depending upon what is in the array, I want to read the arrays of hashes. I wrote this simple script, but does not work. Any solns build = [ "log " , "top" ] log = [ { ''where'' => ''/home/des/blocks/where.rb''}, { ''when'' => ''/home/des/blocks/when.rb''}, { ''bank'' => ''/home/des/blocks/bank.rb''} ] top = [ { ''where'' => ''/home/top/blocks/where.rb''}, { ''when'' => ''/home/top/blocks/when.rb''}, { ''bank'' => ''/home/top/blocks/bank.rb''} ] build.each{ |bu| puts bu bu.each{ |files| puts files }} -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try: build.each do |pu| eval(bu).each do |files| ... end end On Fri, Oct 15, 2010 at 11:48 PM, casper <vikadik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am trying to get this going where i have this build array and then I > have an array of hashes named after the items in the build. Depending > upon what is in the array, I want to read the arrays of hashes. I > wrote > this simple script, but does not work. Any solns > build = [ "log " , > "top" ] > > > log = [ > > { ''where'' => ''/home/des/blocks/where.rb''}, > { ''when'' => ''/home/des/blocks/when.rb''}, > { ''bank'' => ''/home/des/blocks/bank.rb''} > ] > top = [ > > { ''where'' => ''/home/top/blocks/where.rb''}, > { ''when'' => ''/home/top/blocks/when.rb''}, > { ''bank'' => ''/home/top/blocks/bank.rb''} > ] > > > build.each{ |bu| > puts bu > bu.each{ |files| > puts files > > }} > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Erol M. Fornoles http://erolfornoles.posterous.com http://github.com/Erol http://twitter.com/erolfornoles http://ph.linkedin.com/in/erolfornoles -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Oct 15, 4:48 pm, casper <vika...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am trying to get this going where i have this build array and then I > have an array of hashes named after the items in the build. Depending > upon what is in the array, I want to read the arrays of hashes. I > wrote > this simple script, but does not work. Any solns > build = [ "log " , > "top" ] >So you want to iterate over the build array and then do something with the local variable named by the items in that array. There''s not really a nice way of doing that - I would reorganise your data (eg why have two local variables log and top rather than a hash with keys log and top ? Fred> log = [ > > { ''where'' => ''/home/des/blocks/where.rb''}, > { ''when'' => ''/home/des/blocks/when.rb''}, > { ''bank'' => ''/home/des/blocks/bank.rb''} > ] > top = [ > > { ''where'' => ''/home/top/blocks/where.rb''}, > { ''when'' => ''/home/top/blocks/when.rb''}, > { ''bank'' => ''/home/top/blocks/bank.rb''} > ] > > build.each{ |bu| > puts bu > bu.each{ |files| > puts files > > > > }}-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.