Forum: Ruby Re: Building querystrings with ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
87e9a89c53ccf984db792113471c2171?d=identicon&s=25 Kroeger, Simon (ext) (Guest)
on 2006-03-15 11:11
(Received via mailing list)
> }.join("=") }.join("&")
>
> Ignore my stupidity above; this is shorter and less redundant:
>
> "?" << map{ |kv| kv.map{ |e| CGI.escape(e) }.join("=") }.join("&")
>
> Paul.

golfing? :)

"?#{map{|k, v| "#{CGI.escape k}=#{CGI.escape v}"} * '&'}"

cheers

Simon
2abf5beb51d5d66211d525a72c5cb39d?d=identicon&s=25 Paul Battley (Guest)
on 2006-03-15 12:06
(Received via mailing list)
On 15/03/06, Kroeger, Simon (ext) <simon.kroeger.ext@siemens.com> wrote:
> golfing? :)
>
> "?#{map{|k, v| "#{CGI.escape k}=#{CGI.escape v}"} * '&'}"

All right then! :-)

"?"<<map{|h|h.map{|e|CGI.escape(e)}*'='}*'&'

Paul.
This topic is locked and can not be replied to.