In ruby, I often find myself writing the following:
class Foo
def initialize(bar, baz)
@bar = bar
@baz = baz
end
<< more stuff >>
You could use an object as param.
class Foo
attr_accessor :param
def initialize(p)
@param = p
end
end
f = Foo.new
f.param.bar = 1
f.param.bax = 2
This does not save much lines in this case but it will if your class has to handle a large number of param. You could also implement a set_param and get_param method if you want to keep your @param var private.