为什么我做错了 C.respond_to?(:initialize)
class C
def initialize;end
def meth;end
end
C.respond_to?(:initialize) #=> false
C.new.respond_to?(:meth) #=> true as expected
另一种变化
class C
def initialize;end
def meth
pmeth
end
private
def pmeth
respond_to?(:initialize)
end
end