www.ruby-lang.org
www.ruby-lang.org copied to clipboard
Fix /en/documentation/faq/2/index.md
This statement looks wrong to me, It said a A def statement outside of a class definition become private methods of class Object
that is not correct. I can call method (that define outside any class) to object of class Object.
The original statement seems to be correct:
irb(main):001:0> RUBY_VERSION
=> "3.1.2"
irb(main):002:0> def my_test_method; end
=> :my_test_method
irb(main):003:0> Object.public_methods.grep /my/
=> []
irb(main):004:0> Object.private_methods.grep /my/
=> [:my_test_method]
irb(main):005:0> Object.my_test_method
(irb):5:in `<main>': private method `my_test_method' called for Object:Class (NoMethodError)
I think this can be closed without merging. The PR is almost two years old, OP didn't respond to questions, and the current version of the text seems to be correct.