
Issue #19286 has been updated by Eregon (Benoit Daloze). I would guess because `f({a:1,b:2})` used to work before 3.0 and it was passing "one argument", hence arity 1. Also `def m(*); end` cna be called like `m(a:1,b:2)` and that's clearly one argument on the callee side. So from the caller point of view kwargs are at most 1 argument. In general it seems kwargs are considered as 0 (if all optional) or 1 "argument" (from a positional sense), which stems from that history. ---------------------------------------- Bug #19286: What should kwargs' arity be? https://bugs.ruby-lang.org/issues/19286#change-100899 * Author: matsuda (Akira Matsuda) * Status: Open * Priority: Normal * ruby -v: ruby 3.3.0dev (2022-12-28T16:43:05Z master cada537040) +YJIT [arm64-darwin21] * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Hello, guys. It's time for a quick Ruby quiz. Q: What is this method's arity? def f(a:, b:) end It requires two arguments, hence it should be 2? Or if we call this method with one argument, the error message says "wrong number of arguments (given 1, expected 0; required keywords: a, b) (ArgumentError)", which means the arity is 0, maybe? A: The answer is, $ all-ruby -e 'p method(def f(a:, b:) end).arity' ruby-2.1.0-preview1 0 ... ruby-2.1.0 0 ruby-2.1.1 -1 ruby-2.1.2 1 ... ruby-3.1.0 1 it's been 1 since 2.1.2. But why 1? Why not 2 nor 0? I asked this question to the ruby-core people, and ko1's answer was that even he has no idea what the number 1 means.  So I thought it'd be worth asking this question here. ---Files-------------------------------- random_-_ruby-lang_-_Slack.png (40.1 KB) -- https://bugs.ruby-lang.org/