Attr_accessor on class variables

前端 未结 6 1739
Happy的楠姐
Happy的楠姐 2020-12-23 18:57

attr_accessor does not work on the following code. The error says \"undefined method \'things\' for Parent:Class (NoMethodError)\":



        
6条回答
  •  不思量自难忘°
    2020-12-23 19:25

    Parent.class_variable_get(:@@things)
    

    That would be the built-in way. In most cases this should be sufficient I think. No need to have a class variable accessor in the instance.

提交回复
热议问题