阅读背景:

Ruby - 类实例变量getter setter方法

来源:互联网 

Am a Ruby newbie and am trying to define a class with 3 instance variables viz unit_rows, unit_cols and unit_sz. In this class, I want unit_rows and unit_cols to be freely gettable and settable from outside, but I want unit_sz to be calculated (i.e not settable) as (unit_rows * unit_cols). I want the unit_sz instance variable to be gettable from another class but the value should be the product of rows and cols before being returned. This class will be extended with many variables like "unit_sz" and therefore i want to dynamically iterate over all instance variablesAm a Ruby newbie and am trying to define a clas




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: