From: Dan Debertin Date: 2002-07-03T10:04:50+09:00 Subject: Re: Getting CGI arguments as scalars Tom Sawyer writes: > the only trick is to remember to access the paramaters > (i.e.cgi.params) directly if you want to manipulate the parameters > array, as [] will no longer be certain to return such a reference. Chances are you're going to know in advance if your form (or whatever) contains duplicate values. In these cases, why not be consistent and convert? [] returning a different kind of object under certain circumstances seems undesirable to me -- eventually I'm going to forget to invoke .kind_of? on the result. Here's what I ended up doing to solve the same problem: module CGIFeatures # Extensions to CGI to make it act more like a hash. def to_h h = {} # Obviously, this breaks duplicate CGI params. self.keys.each { |k| h[k] = self[k][0] } h end end cgi = CGI.new cgi.extend(CGIFeatures) params_as_hash = cgi.to_h Dan -- airboss@nodewarrior.org www.nodewarrior.org ignorami: n: The art of folding problem users into representational shapes.