0
class A
#define class level attribute called key
class << self
attr_accessor :key
end
end
class B < A
end
B.key = "foo"
B.key # returns "foo"
A.key # returns nil
如果我希望A.key在上述場景中返回「foo」,那麼這種方法是什麼?