Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
How do you know what class defines method foo()?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Logan Capaldo, post: 4498111"] Array.method_defined?(:partition) #=> true Enumerable.method_defined?(:partition) #=> true Same for instance_methods.include?. If we loop forward through ancestors, we get Array as the answer. If we loop backwards we get Enumerable. The problem is, looping backwards will get us the wrong answer if Array overrides partition. I can't think of a good why to do this unless there is a Class#overrides? method. (e.g. Array.overrides?(:partition) #=> false ). [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
How do you know what class defines method foo()?
Top