Reputation:
I have hash based arguments.
method1(:test=>[:arg1, :arg2 => :something])
I need to pass :test
as argument to another method in the following format
from A:
[:arg1, {:arg2=>:something}]
to B:
method2 :arg1, :arg2=>:something
How can I get from A to B?
Upvotes: 1
Views: 1082
Reputation:
if you don't have a lot of things in your hash, you could just loop on the keys and dereference them. What has to happen for this to work is:
Upvotes: 0
Reputation: 7188
If ary = [:art1, {:arg2 => :something}]
then method2 *ary
should do the trick.
Upvotes: 0
Reputation: 18157
How about?
args = {:test => [:arg1, :arg2 => :something]}
method1(args)
method2(*args[:test])
Upvotes: 7