けいじゅ@日本ラショナルソフトウェアです. In [ruby-list :04602 ] the message: "[ruby-list:4602] Re: nif2news.rb ", on Sep/24 17:45(JST) matz / netlab.co.jp (Yukihiro Matsumoto) writes: >まつもと ゆきひろです >|むむ. nilを返すんですか... 知らなかった... > >知らなかった…. (^^;;; >|String#scanの仕様が, 全然マッチしなかった時は, nilを返して, マッチした >|が, ``()''がない場合は, 空の配列を返す仕様になっていると良いと思うんで >|すが... >> matz > >そうしていたつもりです げげ... > % ruby -e 'p "foo".scan(/f/)' > [] > >なんですが.おかしいなあ. 確かになっていますね. そうすると, 私の元のプログラムにバグがあったので, そのせいで勘違いされ たのでしょう. >def actions.call(str) > each do |assoc| > unless (match = str.scan(assoc[0])).empty? > assoc[1].call match > break > end > end >end def actions.call(str) each do |assoc| unless match = str.scan(assoc[0]) assoc[1].call match break end end end これで十分なんですね(^^;;; __ ................................石塚 圭樹@日本ラショナルソフトェア... ----------------------------------->> e-mail: keiju / bc.mbn.or.jp <<---