rdoc icon indicating copy to clipboard operation
rdoc copied to clipboard

Class.new's internal method becomes the method of the class to which the method belongs

Open gemmaro opened this issue 4 years ago • 0 comments

The methods owned by the dynamically generated class inside the method are defined as the methods of the class outside of it. The explanation is a bit complicated, so please see the example.

aaa.rb:

class AAA
  def bbb
    Class.new do
      def ccc; end
    end
  end
end
$ rdoc aaa.rb

There are both bbb and ccc as Public Instance Methods of class AAA.

Screenshot 2021-06-19 at 18-31-44 class AAA - RDoc Documentation

$ rdoc --version
6.3.1

$ ruby --version
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin20]

Thank you.

gemmaro avatar Jun 19 '21 09:06 gemmaro