是否有遵循模式__<original_name>__
的方法并且作为别名而不是__send__
?
答案 0 :(得分:3)
很容易找到与您的模式匹配的方法名称列表:
ObjectSpace.each_object(Module).flat_map(&:instance_methods).uniq.grep(/__\w+__/)
# => [:__send__, :__id__, :__method__, :__callee__, :__dir__]
其中,Kernel#__method__
,Kernel#__callee__
和Kernel#__dir__
不是别名,这给我们留下了两个:
BasicObject#__send__
是Object#send
的别名(您已经提到过这个)BasicObject#__id__
是Object#object_id