class Object | |
def metaclass | |
(class << self; self; end) | |
end | |
end | |
class Foo | |
puts "1. #{self} #{self.__id__}" | |
def meth1 | |
puts "2. #{self} #{self.__id__}" | |
end | |
def self.meth2 | |
puts "3. #{self} #{self.__id__}" | |
end | |
puts "4. #{self.metaclass} #{self.__id__}" | |
def meth3 | |
puts "5. #{self.metaclass} #{self.__id__}" | |
end | |
end | |
Foo.new.meth1 | |
Foo.meth2 | |
Foo.new.meth3 | |
puts "6. #{Foo} #{Foo.__id__}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment