I see this popping up all the time in my code
class Foo
def initialize(foo)
@foo = foo
end
#...
end
This isn't too bad, but it gets worse:
class Foo
def initialize(foo,baz,bar,a,b,c,d)
@foo = foo
@baz = baz
@bar = bar
#etc...
You can sortof get around this by doing something like
@foo, @baz, @bar = foo, baz, bar
But even that feels wrong and is annoying to type. Is there a better way to define instance variables according to arguments?
Edit: There seem to be 2 distinct solutions to this problem. See: