From: David Alan Black Date: 2002-05-14T21:18:32+09:00 Subject: Re: cgi params api Hello -- On Tue, 14 May 2002, Dossy wrote: > 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. But according to Wakou's proposal, cgi["name"] would always return the first value of an array, so your concern about comparing an Array to a String was already addressed. I have to admit I think somehow most of what's come up in this thread seems awfully complicated. Also, we're pretty much going in circles at this point. It might be interesting to write a CGI script (in current cgi.rb style) that does various things with various input, handles unexpected cases, etc., and then "translate" it into some of the proposed styles and see how much clarity is gained, how much typing is saved, etc. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav