On 18 February 2010 12:14, Ralph Shnelvar <li...@ruby-forum.com> wrote:
> Now ... could someone explain to me what the cgi stuff does??

http://ruby-doc.org/core/classes/CGI.html


The thing is, you've not said what your problem is, only asked for a
way do what you think is the way to solve your problem.

to turn a hash into a string of "key=value" for each pair separated by
a space (which is what you've asked for), you could solve a dozen ways
(without extending base ruby classes).

For instance, this seems to do what you want:
{ :a => 'b', :c => 'd' }.inject([]) {|output, pair| output <<
"#{pair[0]}=#{pair[1]}"}.join(" ")

but it's quite smelly code, and doesn't account for potential
confusion that could occur to your output in the event that the hash
was comprised thus:

{ :a => 'b e=f', :c => 'd a=c' }

Explain your *problem*, ie: what is it that's causing you to think
that that hash has to turn into a string; and you may find out that
your approach isn't the most effective, and that someone suggests a
more elegant/efficient/robust way to approach it.


Regards,
Michael

-- 
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-t...@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.

Reply via email to