(一)类变量以及类方法 sample code class BankAccount @@interestRate = 6.5 def BankAccount.getInterestRate() @@interestRate end attr_accessor :balance def initialize(bal) @balance = bal endendputs BankAccount.getInterestRate() 以上代码中描述了如何定义类变量以及如何访问类变量 相关文章: 2021-12-24 2022-12-23 2022-12-23 2021-12-16 2022-12-23 2022-12-23