I
Ittay Dror
Hi,
I'll start with what I understand:
class Foo
class << self
def hi
puts 'HI'
end
end
end
Creates an instance of a singleton class that has the method #hi. So
Foo.hi calls the method defined in the class of Foo -> the singleton
class (which inherits from Class)
My question:
class Bar < Foo
end
Bar.hi --> 'HI'
It looks like two things are happening: 1. Bar points to Foo, so
instances of Bar lookup methods in Foo also. 2. The instance Bar has a
class that inherits from Foo's instance class.
Is this correct? Is there somewhere where I can find the exact flow of
'<' (and '<<')? (or for that matter, specifications how 'splat' behaves
and the '&' operator before blocks)
Thank you,
Ittay
I'll start with what I understand:
class Foo
class << self
def hi
puts 'HI'
end
end
end
Creates an instance of a singleton class that has the method #hi. So
Foo.hi calls the method defined in the class of Foo -> the singleton
class (which inherits from Class)
My question:
class Bar < Foo
end
Bar.hi --> 'HI'
It looks like two things are happening: 1. Bar points to Foo, so
instances of Bar lookup methods in Foo also. 2. The instance Bar has a
class that inherits from Foo's instance class.
Is this correct? Is there somewhere where I can find the exact flow of
'<' (and '<<')? (or for that matter, specifications how 'splat' behaves
and the '&' operator before blocks)
Thank you,
Ittay