From: Brad Dude Date: 2009-09-19T07:54:08+09:00 Subject: Re: Array of hashes issue Jesús Gabriel y Galán wrote: > > @output = [] # or Array.new > > >> � � �@issues.each { >> � � � �|fl| >> � � � �@output << {:id => fl.id, :assignee => fl.assignee, :description >> => fl.description, :status => fl.status, :type => fl.type, :updated => >> fl.updated} >> � � �} >> return @output >> > > When things don't go as expected, you can inspect the variables you > are dealing with, to see what's going on: > >> This is where I want to output my results >> � � � �issueArray = @JiraClass.getIssuesInFilter(newFilterVal[0]) >> � � �issueArray.each { >> � � � �|iss| > p iss >> � � � �iss.each { >> � � � � �|issSecD| > p issSecD >> � � � � �puts issSecD[:description], "\n" >> � � � �} >> � � �} > > > Adding those two lines should give you a clue of what's going on: iss > is one of the hashes in the array. issSecD is an array with each > [key,value]. If you are only interested in the description: > > issueArray = @JiraClass.getIssuesInFilter(newFilterVal[0]) > issueArray.each do |issue| > puts issue[:description] #puts already prints a "\n". don't know if > you actually want 2 of them. > end > > If you want to iterate all of the keys: > > issueArray = @JiraClass.getIssuesInFilter(newFilterVal[0]) > issueArray.each do |issue| > issue.each do |key, value| > puts "#{key} => #{value}" > end > > Hope this helps, > > Jesus. Hi, This was very helpful and worked perfectly for me. But, I'm still not there on what I want to do. I should have explained better. So, now that I have a good hash with my information into it I want to pass it to another method. If I were doing this in PHP or something it would look like this: myFunction(issueHash['id'], issueHash['description'],....) So I guess what I'm missing is how do get my values out using the key? -- Posted via http://www.ruby-forum.com/.