Reputation: 3888
Say I have a method that needs three arguments:
def foo(a, b, c)
end
And I have said arguments in an array:
[a, b, c]
Is there a trivial or one method way of using the array as the arguments, like:
foo(array.some_method)
Upvotes: 1
Views: 694
Reputation: 1453
def foo(*bar)
end
Foo now exacts an array as parameters. You could also make it accept a hash by doing
def foo(bar={})
end
Upvotes: 4