L
Leslie Viljoen
Can someone explain why the following produces different results? In
another question I wrote that by default, programs run inside the
definition-space of Object, but now I think that I was wrong:
class Yoghurt
def self.a
"yoghurt self"
end
def Yoghurt.a
"yoghurt"
end
p Yoghurt.a
p self.a
end
def self.a
"object self"
end
def Object.a
"object"
end
p Object.a
p self.a
------------------------Output:
"yoghurt self"
"yoghurt self"
"object"
"object self"
another question I wrote that by default, programs run inside the
definition-space of Object, but now I think that I was wrong:
class Yoghurt
def self.a
"yoghurt self"
end
def Yoghurt.a
"yoghurt"
end
p Yoghurt.a
p self.a
end
def self.a
"object self"
end
def Object.a
"object"
end
p Object.a
p self.a
------------------------Output:
"yoghurt self"
"yoghurt self"
"object"
"object self"