Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 ruby 3 之前,可以这样做
def test a, **o p a, o end t = [:ok, **{ok: 2}] test *t
它会正确分配
:ok 到 a 和 {ok: 2} 到 o
在 ruby 3 中调用
你会得到
ArgumentError (wrong number of arguments (given 2, expected 1))
是否可以解决将关键字参数保存在第二个位置的 splat 数组参数?