Colin Law wrote in post #981819: > On 15 February 2011 16:46, Paul Bergstrom <li...@ruby-forum.com> wrote: >> Why does this output the same hash again (like hash.inspect) and not >> each key as I want? >> >> @myhash.each { |k,v| "<li>" + k + "</li>" } > > Because it is showing the return value of the method each, not what > you are doing in the block. You need to build up a string in the > block which is the concatenation of your li strings. > Crudely, something like > str = "" > @myhash.each { |k,v| str += "<li>#{k}</li>" } > > Colin
Thanks. I didn't see your respons until now. :-) -- 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, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.