标签:
和ios的@property一样
cattr_accessor 表明是static的getter和setter
attr_accessor 表明是示例的getter和setter
贴一个例子
class Counter cattr_accessor :class_count attr_accessor :instance_count end counter1 = Counter.new counter1.instance_count = 1 counter1.class_count = 1 counter2 = Counter.new p counter2.instance_count #> nil p counter2.class_count #> 1
标签:
原文地址:http://www.cnblogs.com/ziyouchutuwenwu/p/4621651.html