
Issue #20508 has been updated by zverok (Victor Shepelev). Regardless of the rest of the proposal,
I'm not sure how to access the `&` variable, unless I name it.
There is a way: ```ruby def show_block(&) p proc(&) end show_block {} #=> #<Proc:0x00007f485eb07e28 anon_block.rb:5> show_block &-> {} #=> #<Proc:0x00007f485eb07c98 anon_block.rb:6 (lambda)> show_block &:to_i #=> #<Proc:0x00007f485eb07ba8(&:to_i) (lambda)> show_block &method(:puts) #=> #<Proc:0x00007f485eb07a18 (lambda)> show_block #=> in `proc': tried to create Proc object without a block (ArgumentError) ``` Depending on the goals, that might be enough for some introspection. ---------------------------------------- Feature #20508: Explicit access to *, **, &, and ... https://bugs.ruby-lang.org/issues/20508#change-108439 * Author: bradgessler (Brad Gessler) * Status: Open ---------------------------------------- I find debugging and certain meta-programming tasks challenging because there's no explicit APIs for accessing certain types of arguments in Ruby. Here's some example code: ```ruby def splats(one, *, two: nil, **, &) # These work p(*) p(**) # But the block doesn't show a proc. p(&) # This would show [:one, :two, :_] p binding.local_variables end splats(:arg, two: true) do 42 end ``` I'm not sure how to access the `&` variable, unless I name it. The same applies to endless ruby methods. I'd like to see a way to explicitly call bindings for those methods. Something like this (not sure if binding is the right place for it): ```ruby def splats(one, *, true: nil, **, &) binding.arguments # Returns an array binding.keyword_arguments # Returns a hash binding.block_argument # Returns a block end ``` These methods would give me access to the values used to call the method. -- https://bugs.ruby-lang.org/