Created
April 5, 2011 12:49
-
-
Save aprescott/903529 to your computer and use it in GitHub Desktop.
Finding local variable references within the current scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> local_variables | |
=> ["_"] | |
>> a = "" | |
=> "" | |
>> local_variables | |
=> ["_", "a"] | |
>> b = binding; local_variables.select { |var| b.eval(var).object_id == a.object_id } | |
=> ["a"] | |
>> x = a | |
=> "" | |
>> local_variables | |
=> ["_", "a", "b", "x"] | |
>> b = binding; local_variables.select { |var| b.eval(var).object_id == a.object_id } | |
=> ["a", "x"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment