[#38392] Enumerable#gather_each — Tanaka Akira <akr@...>

ときに、複数行をまとめて扱いたいことがあります。

47 messages 2009/05/09
[#38394] Re: Enumerable#gather_each — ujihisa <ujihisa@...> 2009/05/09

ujihisaと申します。

[#38400] Re: Enumerable#gather_each — Yukihiro Matsumoto <matz@...> 2009/05/09

まつもと ゆきひろです

[#38399] Re: Enumerable#gather_each — "Akinori MUSHA" <knu@...> 2009/05/09

At Sat, 9 May 2009 15:30:20 +0900,

[#38405] Re: Enumerable#gather_each — Tanaka Akira <akr@...> 2009/05/10

In article <86r5yy2nrg.knu@iDaemons.org>,

[#38417] Re: Enumerable#gather_each — "Akinori MUSHA" <knu@...> 2009/05/10

At Sun, 10 May 2009 10:08:47 +0900,

[#38524] [Bug #1503] -Kuをつけた時、/[#{s}]/n と Regexp.new("[#{s}]",nil,"n") で実行結果が異なる — sinnichi eguchi <redmine@...>

Bug #1503: -Kuをつけた時、/[#{s}]/n と Regexp.new("[#{s}]",nil,"n") で実行結果が異なる

8 messages 2009/05/22

[ruby-dev:38391] Re: [Bug:1.8] Tempfile and extended Enumerable

From: "Akinori MUSHA" <knu@...>
Date: 2009-05-08 19:06:30 UTC
List: ruby-dev #38391
At Sat, 9 May 2009 02:10:21 +0900,
Tanaka Akira wrote:
> 1.8.8dev で、以下のように、Enumerable に each2 を定義し、
> Tempfile を each2 で繰り返そうとすると、ブロックが呼ばれませ
> ん。

 ブロックが渡されていないのが原因なので、こうすれば直ります。

Index: lib/delegate.rb
===================================================================
--- lib/delegate.rb	(revision 23370)
+++ lib/delegate.rb	(working copy)
@@ -151,12 +151,12 @@ class Delegator
   alias initialize_methods initialize

   # Handles the magic of delegation through \_\_getobj\_\_.
-  def method_missing(m, *args)
+  def method_missing(m, *args, &block)
     target = self.__getobj__
     unless target.respond_to?(m)
-      super(m, *args)
+      super(m, *args, &block)
     end
-    target.__send__(m, *args)
+    target.__send__(m, *args, &block)
   end

   #
@@ -264,11 +264,11 @@ def DelegateClass(superclass)
     def initialize(obj)  # :nodoc:
       @_dc_obj = obj
     end
-    def method_missing(m, *args)  # :nodoc:
+    def method_missing(m, *args, &block)  # :nodoc:
       unless @_dc_obj.respond_to?(m)
-        super(m, *args)
+        super(m, *args, &block)
       end
-      @_dc_obj.__send__(m, *args)
+      @_dc_obj.__send__(m, *args, &block)
     end
     def respond_to?(m, include_private = false)  # :nodoc:
       return true if super


 しかし、 trunk だけ手当てされたのはどういうわけでしょうね?

--
Akinori MUSHA / http://akinori.org/

In This Thread