ruby 3 array argument splat with keyword arguments

Viewed 316

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?

0 Answers
Related