irb icon indicating copy to clipboard operation
irb copied to clipboard

Add a command to peek at otherwise inaccessible context

Open joeldrapper opened this issue 1 year ago • 0 comments

Sometimes we run into inaccessible context when debugging, such as anonymous arguments: *, **, &, ..., or arguments that conflict with Ruby keywords, such as class, end, if.

In these situations, it would be useful to be able to peek at the context. Maybe there’s a better name for this concept, but essentially it would be an IRB command that just returns *args, **kwargs, and &block.

def peek(*args, **kwargs, &block)
  { args:, kwargs:, block: }
end

This would support things like:

peek(*)
peek(**)
peek(&)
peek(...)
peek(class:, end:, if:)

Does this sound useful to anyone else?

joeldrapper avatar Jul 01 '24 01:07 joeldrapper