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

The Archive Base Latest Questions

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

o = Object.new class << o public :puts end o.puts 1. #{o.class.method_defined? :puts} =>

  • 0
o = Object.new

class << o
  public :puts
end
o.puts "1. #{o.class.method_defined? :puts}"              => false
o.puts "2. #{o.class.method_defined? :public_methods}     => true

method_defined? still give me false? even if I declare puts as public, 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-06-14T00:56:43+00:00Added an answer on June 14, 2026 at 12:56 am
    o.class
    => Object
    
    Object.method_defined? :puts
    => false
    
    o.singleton_class
    => #<Class:#<Object:0x2b23858>>
    
    o.singleton_class.method_defined? :puts
    => true
    

    I think the code above shows very clear explanation. If you modify the object itself, you should use singleton_class to access rather than class because the original class does not contain the singleton methods you added.

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

Sidebar

Related Questions

Look at the following two ways to create a new object of class Y:
Given: Object innerProxy = ... Object proxy = java.lang.reflect.Proxy. newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{type}, innerProxy); How
I am tryıng to create new object of other class ın a for loop.
My code: myobj = new Object(); classes.testegy = Class.extend({ init: function (token) { console.log(test
I'm new to object oriented programming in PHP. I included a class and called
object ReassignTest extends App { class X(var i : Int) def x = new
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private
I try to print the name of the class that create the new object.
I have a __new__ method as follows: class MyClass(object): def __new__(cls, *args): new_args =
I have a singleton implemented like this: class Test123(object): _instance = None def __new__(cls,

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.