Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:41:46+00:00 2026-06-14T23:41:46+00:00

After finishing the chapter The Object Model in Metaprogramming Ruby, I got confused. Is

  • 0

After finishing the chapter “The Object Model” in Metaprogramming Ruby, I got confused.
Is an object(instance of some class)’s method the same as the instance methods of its class in Ruby?
It sounds true. because we know the object’s methods stored in its class.

class W;end

W.methods == Class.instance_methods # => true

# Also

String.instance_methods == "abc".methods # => true

W is an instance of Class. but if I reopen W and define a new method for it, than make confuse.

class W
  def self.foo
     "bar"
  end
end

W.methods == Class.instance_methods  # => false

W is a instance of Class, and W‘s methods is Class‘s instance method. but if :foo didn’t get stored in Class, than where is it stored?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:41:48+00:00Added an answer on June 14, 2026 at 11:41 pm

    The method wtf is stored inside the W class, not in Ruby’s Class class.

    Think of it as inheritance, when you define a method in the inheriting class it is not available in the inherited class. Likewise, when you define a method in the W class it is not available in the Class class.
    You do not affect the inherited class when you add a method in the inheriting class.

    Although I do not recommend messing with Ruby’s internal Class class, you can add methods to it by monkey patching it:

    class Class
      def self.wtf
         "wtf"
      end
    end
    

    Now Class.methods.grep /wtf/ will return you the added method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We got a problem with NUnit 2.5.3: nunit-console.exe does not return after finishing all
In Internet Explorer I was testing some things with Privacy security settings. After finishing
After finishing my C++ class it seemed to me the structs/classes are virtually identical
I spend some time implementing a quicksort algorithm in C#. After finishing I compared
So I'm trying my hand at some C++ after finishing up an introductory book,
I want to raise the some event in Java after finishing the reading of
Can I add values to an instance of an object after I have used
In delegate method of UIalerview I am trying to show another alert after finishing
how can i activate the readonly back after finishing the edit of the input
I want to display a success msg after finishing an Ajax call. I tried

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.