Issue #15646 has been updated by alanwu (Alan Wu).


Ah, I didn't know `initialize` is always private:

```ruby
irb(main):001:0> class A
irb(main):002:1>   def initialize
irb(main):003:2>   end
irb(main):004:1> end
=> :initialize
irb(main):005:0> A.new.initialize
Traceback (most recent call last):
        4: from /opt/rubies/2.6.1/bin/irb:23:in `<main>'
        3: from /opt/rubies/2.6.1/bin/irb:23:in `load'
        2: from /opt/rubies/2.6.1/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
        1: from (irb):5
NoMethodError (private method `initialize' called for #<A:0x00007faedb0bf428>)
```

----------------------------------------
Bug #15646: method_defined? inside method_added behaves differently for `initialize`
https://bugs.ruby-lang.org/issues/15646#change-76998

* Author: alanwu (Alan Wu)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-03-08 trunk 67194) [x86_64-darwin18]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Repro:
```ruby
class MethodAddedSpecialCase
  def self.method_added(name)
    puts "#{name} added, method_defined?: #{method_defined?(name)}"
  end

  def hello
  end

  def initialize
  end
  
  def world
  end
end
```

Output:
```
hello added, method_defined?: true
initialize added, method_defined?: false
world added, method_defined?: true
```



-- 
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>