0
例如,我怎麼能實現以下功能Ruby - 對象是否可以訪問或標識實例化它的對象?
class A
def initialize
b = B.new
end
end
class B
def initialize
puts #how can I find out who instantiated me
end
end
例如,我怎麼能實現以下功能Ruby - 對象是否可以訪問或標識實例化它的對象?
class A
def initialize
b = B.new
end
end
class B
def initialize
puts #how can I find out who instantiated me
end
end
參見[這裏](http://stackoverflow.com/questions/8720677/the-name-of-the-class-that- newed-我級/ 8720780#8720780)。 – Linuxios