From: Anton Ivanov Date: 2008-09-12T09:18:37+09:00 Subject: Re: pass by reference in each loop Xiong Chiamiov wrote: > > I don't think I understood what you were suggesting the first time. If > I understand what you're suggesting, it is to have the values themselves > in the array, rather than variables pointing *to* those values, yes? > > I need to know specifically which values are which, however, as they get > passed back into different parts of the output, so I'm thinking I'd have > to use a hash, something like > > hash = { > 'a' => 'this is actually input', > 'b' => 'not hardcoded', > ... > } > > so that I could assign them appropriately afterwards: > > hash.each {|key, value| key = value} > > although, looking at that now, I don't think that it would work. > > But as far as hash mapping (if that's what I have to do), I suppose I > could use one of the methods in this thread > (http://www.nabble.com/Iterating-through-a-hash-td19074540.html), right? > > I appreciate your help. I think you're getting yourself more and more confused. Quit posting, fire up irb and play around. What do you get when you do hash.each {|key, value| key = value} ? Is there any difference between [1,2,3].each {|x|} and a,b,c=1,2,3; [a,b,c].each {|x|}? etc. -- Posted via http://www.ruby-forum.com/.