url = 'SomeUrl'
args{ someKey: 'Value',
key2: 'Value2'
}
该方法当前将这两个都用作参数。我将这两个参数合并为一个散列,如下所示:
opts = {
Hello: {
Name: 'John',
Version: '1.0'
},
World: {
platformVersion: '3.4x',
helloVersion: '2.3'
}
}
我正在尝试的是将这两个哈希结合起来,并在运行时通过这种方法将它们分开:
def initialize(opts)
#this is how it was done before
SomeClass.for(:remote, opts)
#What I want here is to split that hash into two arguments
end
答案 0 :(得分:0)
opts = {
Hello: {
Name: 'John',
Version: '1.0'
},
World: {
platformVersion: '3.4x',
helloVersion: '2.3'
}
}
def initialize(opts)
SomeClass.for(:remote, opts[:Hello], opts[:World])
end
这是您想要的吗?
SomeClass.for
方法将收到三个参数:
:remote
{ Name: 'John', Version: '1.0' }
{ platformVersion: '3.4x', helloVersion: '2.3' }