Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gemmaro opened this issue Jun 19, 2021 · 0 comments

Comments

@gemmaro
Copy link
Contributor

gemmaro commented Jun 19, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant