ruby-on-railsrubyarrayshashsinatra

convert a list of hashes to a argument for a method


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?


Solution

  • How about?

    args = {:test => [:arg1, :arg2 => :something]}
    method1(args)
    
    method2(*args[:test])