Ruby pass numbers as key (key-value) to **kwargs
<p>How to pass numbers as key (key-value) to **kwargs? In other words, why can't numbers be passed as key (key-value) to **kwargs? Here's the error:</p>

<p><strong>Edit:</strong></p>

<pre><code>def func(**kwargs)
 puts kwargs.class
 p kwargs
end

func(a={:alpha =&gt; 1, :beta =&gt; 2, :gamma =&gt; 3})
# wrong number of arguments (1 for 0) (ArgumentError)
func(n = {1 =&gt; 'alpha', 2 =&gt; 'beta', 3 =&gt; 'gamma'})
</code></pre>

<p>In Python, this would work:</p>

<pre><code>def func(**kwargs):       
        print(type(kwargs).__name__)
        print(kwargs)

func(a={'alpha': 1, 'beta': 2, 'gamma': 3})
func(n = {1: 'alpha', 2: 'beta', 3: 'gamma'})
</code></pre>

<p>Please help. </p>

<p>kwargs means: <strong>K</strong>ey<strong>w</strong>ord<strong>A</strong>rguments</p>

<p>In ruby's case you can only pass a symbol as the key. (Correct me if there's anything else)</p>

<p>So Things like that won't work:</p>

<pre><code>func("a" =&gt; "foo")
func(1 =&gt; "bar")
func(Object.new =&gt; "baz")
</code></pre>

<p>These will all create a hash and pass it to the function as a first positional argument. But your method doesn't have any positional parameters. Hence the error.</p>

<p>You can only use:</p>

<pre><code>func(a: "this")
func(whatever: Object.new)
</code></pre>

python ruby