Skip to content

Instantly share code, notes, and snippets.

@zzak
Created March 4, 2011 01:47
Show Gist options
  • Save zzak/854013 to your computer and use it in GitHub Desktop.
Save zzak/854013 to your computer and use it in GitHub Desktop.
class A
@@a = 1
@a = 2
a = 3
end
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