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

  • Home
  • SEARCH
  • 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 5850635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:10:06+00:00 2026-05-22T13:10:06+00:00

It looks like const_missing is an instance method of Object . If so, why

  • 0

It looks like const_missing is an instance method of Object. If so, why doesn’t this code work?

module Extensions
  def const_missing(c)
    puts c
  end
end

class Object
  include Extensions
end

NonExistent.new

In order to get it to function correctly, I have to change def const_missing to def Object.const_missing. Why?

  • 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-05-22T13:10:06+00:00Added an answer on May 22, 2026 at 1:10 pm

    This is just a consequence of the way method calls are resolved in Ruby.

    First, singleton methods are checked. Then instance methods of the class, followed by the ancestors (which will be the included modules, then superclasses with their included modules).

    So you could define Object.const_missing directly, or include your Module in the singleton class of Object:

    class << Object
      include Extensions
    end
    
    NonExistent # => prints "NonExistent"
    

    You could also monkeypatch Module#const_missing.

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

Sidebar

Related Questions

I have some code that looks like: static const std::string and( AND ); This
I see a lot of c++ code that looks like this: for( const_iterator it
I have code that looks like this: class T {}; class container { const
I have a good amount of code which looks like this: rule requestIntHoleTemplate {
I have a piece of C code that looks like this: const char (*foo)[2]
The function header for pthread_create looks like this: int pthread_create(pthread_t * thread, const pthread_attr_t
My JSON string looks like this, [{id : 38,heading : Can you also figure
This question probably looks a lot like IDE for ironpython on windows question here
I'm working with Ripper sexp expressions, it looks like this: [:program, [[:class, [:const_ref, [:@const,
I have a copy constructor that looks like this: Qtreenode(const QtreeNode * & n)

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.