Hi guys,
first sorry my poor english. I’m a spanish speaker from argentina
seing a video-conf from Dave T. on metaprogramming I rose these
questions:
who is the reciever? where are stored the method definitions?
class Dave
class << self
def hi
puts 123
end
def self.hi
puts 456
end
end
Foo.c #=> Class method
Foo.metaclass.b #=> Class method of the metaclass
Foo.c #=> Class method
Foo.new.d #=> Instance method
Foo.e #=> Class method of the metaclass
Thanks Bernardo
still a bit confusing for me but you provided enough working material to
analyze
looks like a chain: a method of the metaclass of the Foo’s metaclass
Bernardo Rufino wrote:
Will produce:
Foo.c #=> Class method
Foo.metaclass.b #=> Class method of the metaclass
Foo.c #=> Class method
Foo.new.d #=> Instance method
Foo.e #=> Class method of the metaclass
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.