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 6166617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:22:07+00:00 2026-05-23T22:22:07+00:00

In the top-level : unbinded_method = method :puts #=> Object(Kernel)#puts(*arg1) but I did this

  • 0

In the top-level :

unbinded_method = method :puts

#=> Object(Kernel)#puts(*arg1)

but I did this

obj = Object.new

obj.puts 'wow'

I got an undefined error

so I assumed the Kernel module didn’t include in the singleton class of obj, so I did

obj.instance_eval do

include Kernel

end

but I got error again:

NoMethodError: undefined method `include' for #<Object:0x00000100b14dc8>
  • 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-23T22:22:08+00:00Added an answer on May 23, 2026 at 10:22 pm

    Why can’t I include Kernel in the singleton class of an instance of Object

    Uhm, you can:

    obj = Object.new
    obj.singleton_class.ancestors
    # => [Object, Kernel, BasicObject]
    
    class << obj
      include Kernel
    end
    obj.singleton_class.ancestors
    # => [Object, Kernel, BasicObject]
    

    Note: obviously, includeing Kernel into an instance of Object doesn’t actually do anything, because Kernel is already in the ancestor chain, and mixins can only appear once in the ancestor chain. But if you include another mixin, that will work:

    obj = Object.new
    obj.singleton_class.ancestors
    # => [Object, Kernel, BasicObject]
    
    class << obj
      include Enumerable
    end
    obj.singleton_class.ancestors
    # => [Enumerable, Object, Kernel, BasicObject]
    

    but I did this

    obj = Object.new
    
    obj.puts 'wow'
    

    I got an undefined error

    No, you didn’t. This is the error you got:

    # NoMethodError: private method `puts' called for #<Object:0xdeadbed>
    

    It tells you right there in the error what the problem is: Kernel#puts is private, and in Ruby, private methods can only be invoked as the result of a receiverless message send. For example like this:

    obj.instance_eval do puts 'wow' end
    # wow
    

    or just

    obj.send :puts, 'wow' # send cirvumvents access protection
    # wow
    

    so I assumed the Kernel module didn’t include in the singleton class of obj […]

    Why did you assume instead of just check?

    obj.singleton_class.ancestors.include? Kernel # => true
    

    so I did

    obj.instance_eval do
      include Kernel
    end
    

    but I got error again:

    NoMethodError: undefined method `include’ for #

    Again, the error message already tells you everything you need to know: Object doesn’t have an include method, nor is there one in its ancestor chain. include is a method of the Module class, but obj is an Object, not a Module.

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

Sidebar

Related Questions

$0 is the variable for the top level Ruby program, but is there one
I've got a data structure which at the top level is a dictionary, and
I need to reference a variable of a top level class from a method
Can a cookie be shared between two sites on the same top level domain?
When commiting to SVN I can add a top level commit message to detail
What is the best design decision for a 'top-level' class to attach to an
I have an asp:Menu and it contains a top level menu item that points
What is the best way to stop a user from resizing the top-level window
I am looking for a way to clean up the mess when my top-level
On the page http://tesselaar.com/gallery/ I have a heading (level 1) at the top of

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.