2
我想找出哪些模塊包含在特定的類中,但不包括其祖先。例如: -如何知道某個類中包含了哪些模塊
module M; end
module N; end
class A; include M; end
class B < A; include N; end
p B.included_modules
#=> [N, M, Kernel]
# I want only N
我不能使用B.included_modules[0]
,因爲我不知道B
多少模塊包括。
或'p B.included_modules - B.superclass。 included_modules' :) – BernardK
@BernardK:'如果'你知道A是....'else' :) –