On 2002.05.15, David Alan Black <dblack / candle.superlink.net> wrote:
> > > You could define your #[] to return an empty array instead of nil
> > > for non-existent keys.
> >
> > Given the parameters:  foo=bar&quux=
> >
> > There's a big semantic difference between cgi["foo"], cgi["quux"]
> > and cgi["abc"].
> >
> > cgi["foo"].to_a         # => ["bar"]
> > cgi["quux"].to_a        # => []
> > cgi["abc"].to_a         # => nil
> 
> I was responding to the [0] point quoted above, specifically the
> concern that nil wouldn't respond to #[].

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.

-- 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)