On Wed, 29 Oct 2003 21:44:50 +0900
In article <1067431487.741441.12489.nullmailer / picachu.netlab.jp>
[[ruby-dev:21766] Re: ruby 1.8.1 preview1 schedule]
matz / ruby-lang.org (Yukihiro Matsumoto) wrote:

> |TypeError: `to_a' did not return Array
> |	from /usr/local/lib/ruby/1.8/cgi.rb:804:in `Array'
> |	(snip)
> |
> |でもって,よくよく調べたら CGI::Value を strip してから渡すとこ
> |れになるようです。
> 
> ふむ。以下のパッチで事態は変化しますか?
> 
> --- lib/cgi.rb	29 Oct 2003 06:53:48 -0000	1.62
> +++ lib/cgi.rb	29 Oct 2003 12:44:13 -0000
> @@ -1154,7 +1154,5 @@ class CGI
>        def to_a
> -        @params
> -      end
> -      def to_ary                # to be rhs of multiple assignment
> -        @params
> +        @params || [self]
>        end
> +      alias to_ary to_a   # to be rhs of multiple assignment
>      end

これでも良いです。

ところで,Object#to_a が廃止されると,Array(1) とかは何を返すの
でしょうか? [1]? NoMethodError?

現在は to_a を undef すると NoMethodError のようですが,そうする
とまた同じことになると思うので [ruby-dev:21759] のパッチのほうが
ベターだと思います。

寧ろ CGI::Value が String を継承するのを止めて Delegator にして,
String#〜 が String を返すようにしてくれたほうが有り難いと思うの
ですが,どうでしょう?  strip だの gsub だのを掛けた後にまだ 
CGI::Value なんていう細工が必要とは思えないので。


―[ Tietew ]――――――――――――――――――――――――――
 メ : tietew / tietew.net / tietew / raug.net / tietew / masuclub.net
ホペ: http://www.tietew.net/     Tietew Windows Lab.
      http://www.masuclub.net/   鱒倶楽部
指紋: 26CB 71BB B595 09C4 0153  81C4 773C 963A D51B 8CAA