From: "Jun Aruga (he / him)" Date: 2022-10-21T15:22:35+02:00 Subject: [ruby-core:110465] Questions about anonymous rest and keyword rest argument forwarding Hello, I am testing new features in Ruby 3.2.0 now, and I have questions about the "anonymous rest and keyword rest argument forwarding". https://www.ruby-lang.org/en/news/2022/09/09/ruby-3-2-0-preview2-released/ https://bugs.ruby-lang.org/issues/18351 The example below is mentioned on the release note. ``` def foo(*) bar(*) end def baz(**) quux(**) end ``` 1. The "*" is called the "anonymous rest argument", and "**" is called the "keyword rest argument", right? 2. I think the "*" and "**" themselves are not new in Ruby 3.2.0. Do you know in which Ruby version these arguments were introduced? ``` $ cat annonymous_args2.rb def foo(*) p "foo" end def baz(**) p "baz" end foo([1, 2]) baz(:a => 'A', :b => 'B') ``` The code works in Ruby 3.1.1. ``` $ /usr/local/ruby-3.1.1/bin/ruby annonymous_args2.rb "foo" "baz" ``` 3. The following code works in Ruby 3.2.0 preview2. ``` $ cat annonymous_args1_2.rb def bar(*) puts "bar" p [*] end def foo(*) bar(*) end foo(1, 2, 3) ``` ``` $ which ruby /usr/local/ruby-3.2.0-preview2/bin/ruby $ ruby annonymous_args1_2.rb bar [1, 2, 3] ``` But the following code doesn't work with the syntax errors. Do you know what's wrong? ``` $ cat annonymous_args1_3.rb def quux(**) puts "quux" p {**} end def baz(**) quux(**) end baz(:a => 'A', :b => 'B') ``` ``` $ ruby annonymous_args1_3.rb annonymous_args1_3.rb:3: syntax error, unexpected **arg p {**} annonymous_args1_3.rb:10: syntax error, unexpected end-of-input, expecting '}' baz(:a => 'A', :b => 'B') ``` ``` $ which ruby /usr/local/ruby-3.2.0-preview2/bin/ruby ``` Thanks! -- Jun | He - Him | Timezone: UTC+1 or 2, Czech Republic See for the timezone. Unsubscribe: