www.ruby-lang.org icon indicating copy to clipboard operation
www.ruby-lang.org copied to clipboard

Fix /en/documentation/faq/2/index.md

Open Abhideveloper28 opened this issue 3 years ago • 2 comments

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.

Abhideveloper28 avatar May 24 '22 14:05 Abhideveloper28

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)

stomar avatar Oct 30 '22 22:10 stomar

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.

jcsahnwaldt avatar Apr 05 '24 22:04 jcsahnwaldt