How many times have we seen this:

class X
  attr_accessor :arg1, :arg2, :arg3, :arg4

  def initialize(arg1, arg2, arg3, arg4)
    @arg1, @arg2, @arg3, @arg4 = arg1, arg2, arg3, arg4
  end
end


Wouldn't it be nice if we (ok, I) could instead write


def initialize(arg1, arg2, arg3, arg4)
  initargs
end


and have initargs create the attr_accessor as well as the assignments.

I know I can do this in 1.9.2

class X
  def initialize(arg1)
    self.class.send(:attr_accessor, :arg1)
    @arg1 = arg1
  end
end


So is it possible in Ruby to introspect on the _names_ of arguments passed in to a function so that I can build the attr_accessor as well as the assignments?