class BankAccount @@interestRate =6.5 def BankAccount.getInterestRate() @@interestRate end attr_accessor :balance def initialize(bal) @balance = bal end end puts BankAccount.getInterestRate()
以上代码中描述了如何定义类变量以及如何访问类变量
posted on
2008-01-04 13:41coderlee
阅读(476)
评论(0)
收藏举报