Issue #12131 has been updated by Eregon (Benoit Daloze).

Status changed from Open to Closed

Right, it makes sense with the current semantics.
I think this is surprising though, and possibly causing bugs for people expecting the method to be called only for methods defined after method_added/singleton_method_added.
However, since no one seems bothered too much, let's close this.

----------------------------------------
Bug #12131: Should defining singleton_method_added call itself?
https://bugs.ruby-lang.org/issues/12131#change-78942

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
This seems surprising:

~~~
obj = Object.new
def obj.singleton_method_added(n)
  p n
end
def obj.new_singleton_method; end
~~~

outputs

~~~
:singleton_method_added
:new_singleton_method
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>