Hello --

On Sun, 12 May 2002, Wakou Aoyama wrote:

> Hi,
>
> $/ = "\0"
> "value1\0value2\0value3\0".to_a  # ==> ["value1\0", "value2\0", "value3\0"]
>
>
>
> cgi["name"]       # => "value1\0value2\0value3\0"
> cgi["name"].to_a  # => ["value1", "value2", "value3"]
>                   # ( auto chomp("\0") )
>
> if cgi["name"] has only one value then cgi["name"] return "value".
>
> cgi["name"]       # => "value"
> cgi["name"].to_a  # => ["value"]
>
> How about?

An array seems to me like a more natural container for multiple values
than a string.  I guess I'm not sure what you would ever do with such
a string, except split it on $/ and get an array :-)

Also, I don't think you can rely on the one-value thing.  Unless you
test, you can't be sure that the one value is not a string composed of
several values.

I think the problem with finding the perfect (non-array) syntax is
that the input simply isn't constrained to be one thing or another
(string or array).  So deciding in advance to treat it like one or the
other will always open up the possibility of handling the wrong one.



David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav