【发布时间】:2012-03-07 20:31:18
【问题描述】:
我有一个类似下面的类,我使用实例变量(数组)来避免使用大量方法参数。
它按我的预期工作,但这是一个好习惯吗? 实际上我不认为这会起作用,但我猜类方法在其他语言中不能作为静态方法工作。
class DummyClass
def self.dummy_method1
@arr = []
# Play with that array
end
def self.dummy_method2
# use @arr for something else
end
end
【问题讨论】: