I have a method with a lengthy list of optional arguments, such as:
def foo(foo = nil, bar = nil, baz = nil, qux = nil)
# no-op
end
I thought that calling the method and passing a split hash as a parameter would map the hash items to parameters by matching the key with the method parameter:
params = { bar: 'bar', foo: 'foo' }
foo(*params)
Unfortunately, when I examine the local variables after calling the method with a split hash, I get exactly what I'd expect if I passed in a split array, but it's not what I was hoping for:
foo == [:bar, 'bar'] # hoped: foo == 'foo'
bar == [:foo, 'foo'] # hoped: bar == 'bar'
What am I lacking here?