From: Dossy Date: 2002-05-14T21:00:58+09:00 Subject: Re: cgi params api On 2002.05.14, David Alan Black wrote: > > The problem is when cgi["key"] wants to return an array. > > Then "foo" == cgi["key"] will fail since you're comparing > > a String to an Array. > > But see above... > > > > cgi["key"] return first value as String. > > ...so the string comparison would work. cgi["key"] could only returns a String if there's only one value for "key" -- otherwise, you have to return some other object type that knows all of the values but only returns the first one when asked (through #to_s, or whatever). That's why I'm using the CGI::Param class that's a subclass of String. Otherwise, string comparisons don't work if you don't explictly use #to_s. In other words, if the params were: foo=bar&foo=baz cgi['foo'].to_s == "bar" # => true cgi['foo'].to_a == ["bar", "baz"] # => true cgi['foo'] == "bar" # => false !!! Making CGI::Param subclass of String makes it possible for the third case to be true, which is exactly what I've been looking for. -- 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)