Skip to content

Instantly share code, notes, and snippets.

@jlecour
Created March 1, 2016 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlecour/5d1bad625a7b15b7afff to your computer and use it in GitHub Desktop.
Save jlecour/5d1bad625a7b15b7afff to your computer and use it in GitHub Desktop.
def my_method(arg1:, arg2:)
# how to get the keys/values or arguments, when they also exist as a method?
# instance_variable_get("…"), and instance_variable_names are for instance variables
end
# concrete example :
def go_to(step:, options: [])
# when using Pry, the step variable is shadowed by the debugger `step` method
end
@jjaffeux
Copy link

jjaffeux commented Mar 1, 2016

require "pry"
require "pry-byebug"

def go_to(step:, options: [])
  binding.pry
  "Going to step: #{step}"
end

go_to(step:1)
From: /Users/joffreyjaffeux/Projects/test.rb @ line 8 Object#go_to:

    6: def go_to(step:, options: [])
    7:   binding.pry
 => 8:   "Going to step: #{step}"
    9: end

[1] pry(main)> binding.local_variable_get(:step)
=> 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment