6

Before ruby 3 it was possible to do sth like this

def test a, **o
  p a, o
end
t = [:ok, **{ok: 2}]
test *t

it would properly assign

:ok to a and {ok: 2} to o

invoking in ruby 3

you will get

ArgumentError (wrong number of arguments (given 2, expected 1))

Is there work around to splat array argument that holds keyword argument on second position?

mingle
  • 1,567
  • 1
  • 16
  • 19
  • Does this answer your question? [ArgumentError after updating from Ruby 2.7 to Ruby 3.0](https://stackoverflow.com/a/65471481/895789) – Alter Lagos Oct 19 '21 at 23:05

1 Answers1

0

If you need to send the second parameter as a hash you need to do next:

def test a, o
  p a, o
end
t = [:ok, {ok: 2}]
test *t

because of the separating keyword and positional arguments.

kunashir
  • 917
  • 8
  • 21