From: Kazuhiro HIWADA Date: 1998-10-30T08:59:28+09:00 Subject: [ruby-list:10481] Enumerable#collect bug? ひわだです。 以下の script で collect がちょっと予想外の動作をします。 1.1c0, 1.1c6 を使っています。 module Enumerable def mycollect ; a=[]; self.each{|i| a< c = CombinationIterator.new([1,2,3],2) # rbc0> c.each{|i|p i} [1, 2] [1, 3] [2, 3] nil #予想通り rbc0> c.collect{|i|i} [[1, 2], nil, nil, nil, [1, 3], nil, nil, nil, [2, 3], nil, nil, nil] #あれ? rbc0> c.mycollect{|i|i} [[1, 2], [1, 3], [2, 3]] #これは予想通り collect ってこういうもの?…じゃないですよね。 #仕様? ^^;。とりあえず再定義しとくかな… -- 檜田 和浩 ( hiwada@kuee.kyoto-u.ac.jp )