Ruby中是否有一种方法可以在方法中找到调用方法的名称?
例如:
class Test
def self.foo
Fooz.bar
end
end
class Fooz
def self.bar
# get Test.foo or foo
end
end
发布于 2018-03-21 09:26:12
puts caller[0]
或者
puts caller[0][/`.*'/][1..-2]
https://stackoverflow.com/questions/-100003648
复制相似问题