On 2002.05.16, Michael Campbell <michael_s_campbell / yahoo.com> wrote:
> > Right, and as I said, defining #[] to return [] instead of nil
> > for non-existent keys means that it's no longer possible to test
> > for the existance of a key by saying:
> > 
> >   cgi["key"].nil?
> > 
> > Now, a parameter that looks like "foo=" appears the same as if
> > foo wasn't defined, but "foo=" is very different than if foo
> > weren't passed as a parameter at all.
> 
> Is that important?  If so, conceptually or pragmatically?

Conceptually, so far.  I haven't come across any good examples
of pragmatic reasons why it's important.

I realized that the suggestion I made is probably fine:

  query string:  foo=bar&quux=

cgi["foo"].to_a     # => ["bar"]
cgi["quux"].to_a    # => [""]
cgi["abc"].to_a     # => []

You can test for a parameter that wasn't in the query string
by asking cgi["abc"].to_a.size == 0 or cgi["abc"].to_a == [].

(Hi, Michael.  Small world ... ;-) )

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)