-
-
Save zzak/854013 to your computer and use it in GitHub Desktop.
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
class A | |
@@a = 1 | |
@a = 2 | |
a = 3 | |
end |
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
last_a = nil | |
tracer = lambda { |event, _, _, _, bind, _| | |
value = (eval("a", bind) rescue nil) | |
last_a = value if value | |
} | |
set_trace_func(tracer) | |
load "./a.rb" | |
arr = [] | |
arr << A.class_variable_get(:@@a) | |
arr << A.instance_variable_get(:@a) | |
arr << last_a | |
puts arr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment