Skip to content

Instantly share code, notes, and snippets.

@samnang
Forked from zzak/a.rb
Created March 5, 2011 03:23
Show Gist options
  • Save samnang/856070 to your computer and use it in GitHub Desktop.
Save samnang/856070 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