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?
I think the code above shows very clear explanation. If you modify the object itself, you should use
singleton_classto access rather thanclassbecause the original class does not contain the singleton methods you added.