From: Dossy Date: 2002-05-14T22:17:03+09:00 Subject: Re: cgi params api On 2002.05.14, David Alan Black wrote: > > 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. Ah, but the problem is what if the "name" param has multiple values? If cgi["name"] only returns a String, then you couldn't use the [] operator to get the array. You'd have to do something like cgi.param_array("name") which returns Array. That's pretty awkward, IMHO. I like being able to say cgi["name"] and get a String, say cgi["name"].to_s and get the same string but say cgi["name"].to_a and get an array of string values. I don't see how you can do this without making the object returned by CGI#[] a class that subclasses String but defines #to_a. I'd love to be enlightened by an example in working code ... > 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. Someone write a CGI using cgi.rb, and I'll write it using my newly writen Panoptic::CGI ... -- 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)