Re: [Rails] Hash to list fails

2011-02-15 Thread Jim Ruther Nill
ooops. sorry. should be @myhash.collect {|k,v| "#{k} is #{v}"}.join On Wed, Feb 16, 2011 at 8:19 AM, Jim Ruther Nill wrote: > can't you use collect? and then join the result? > > @myhash.each {|k,v| "#{k} is #{v}"}.join > > > On Wed, Feb 16, 2011 at 12:46 AM, Paul Bergstrom wrote: > >> Why does

Re: [Rails] Hash to list fails

2011-02-15 Thread Jim Ruther Nill
can't you use collect? and then join the result? @myhash.each {|k,v| "#{k} is #{v}"}.join On Wed, Feb 16, 2011 at 12:46 AM, Paul Bergstrom wrote: > Why does this output the same hash again (like hash.inspect) and not > each key as I want? > > @myhash.each { |k,v| "" + k + "" } > > -- > Posted vi

Re: [Rails] Hash to list fails

2011-02-15 Thread kedar mhaswade
Or since only keys are needed, use each_key iterator. Also, I think ri should say that the "method" each "returns" the same Hash on which you called the method. -Kedar On Tue, Feb 15, 2011 at 8:57 AM, Colin Law wrote: > On 15 February 2011 16:46, Paul Bergstrom wrote: > > Why does this output

Re: [Rails] Hash to list fails

2011-02-15 Thread Colin Law
On 15 February 2011 16:46, Paul Bergstrom wrote: > Why does this output the same hash again (like hash.inspect) and not > each key as I want? > > @myhash.each { |k,v| "" + k + "" } Because it is showing the return value of the method each, not what you are doing in the block. You need to build u

[Rails] Hash to list fails

2011-02-15 Thread Paul Bergstrom
Why does this output the same hash again (like hash.inspect) and not each key as I want? @myhash.each { |k,v| "" + k + "" } -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group