Substitute method arguments in Ruby
how to bind a set of arguments to a variable and then use the variable as argument for a method, e.g.
my_method(arg_a, arg_b, arg_c, arg_d, arg_e)
should be expressed like something like that
my_args = [arg_a, arg_b, arg_c, arg_d, arg_e] my_method(my_args)
But that doesn't work 'cause my_method expects 5 args but only get the array as one arg. I have few methods with the same arguments set so how to get this working to get DRYer code?
You should use the splat operator. Try this:
my_args = [arg_a, arg_b, arg_c, arg_d, arg_e] my_method(*my_args)