Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们如何扩展 attr_accessor。是否可以?
对于检查实例变量, attr_reader 就足够了。您不需要 attr_accessor。
我认为为一个类扩展它的基本公式是这样的:
class SomeClass def self.attr_accessor(param) ...some code... end end