I want to know how ruby interpreter works.Well let's look at the bellow In irb console if write
Class.is_a? Class #=> returns -> true
I would like to know how this is returning true. What is happening underneath.
class A
def hello
puts 'hello'
end
end
A.is_a? A # returns false
Why it's returning false here?
Can someone explain how this is being done underneath.I am not asking for Ruby
obeject class hierarchy but look Class.is_a? Class
is true
then A.is_a? A
should be true because A is a Class
.But A.is_a? A
is false why?
Another example
Module.is_a? Class # returns true
Class.is_a? Module # returns true
I mean how?
Because Module
can't be instantiated where Class
can be and there are other differences as well between Mudule
and Class
.
Then how come those expression returning true
that means there are some logic behind this.
Can someone explain that logic or the magic happening here.
I am really interested to know this.
Please help me understand Ruby
interpreter technique
Thanks in advance.