I have a piece of test code:
def asdf(id: nil, field: nil, state: nil)
puts "id: #{id}, field: #{field}"
end
def test(a, b, *args)
# a, b are needed only inside #test
yield(state: :created, *args)
end
test('a', 'b', id: 'xyz', field: :asd) { |*args| asdf(*args) }
It generates a syntax error:
syntax error, unexpected *
yield(state: :created, *args)
What is the correct way to call a block with a named parameter and an argument list? What is the idiomatic way to do this?
I also tried passing &block to test and doing block.call(state: :created, *args) with no luck.