李超

cc编程笔记本。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

(一)类变量以及类方法
sample code

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:41  coderlee  阅读(471)  评论(0编辑  收藏  举报