trace_var(symbol, cmd ) â nil
trace_var(symbol) {|val| block } â nil
trace_var(symbol) {|val| block } â nil
Instance Public methods
Controls tracing of assignments to global variables. The parameter +symbol_
identifies the variable (as either a string name or a symbol identifier).
cmd (which may be a string or a Proc
object) or block
is executed whenever the variable is assigned. The block or
Proc
object receives the variable's new value as a
parameter. Also see Kernel::untrace_var
.
1 2 3 | trace_var : $_ , proc {|v| puts "$_ is now '#{v}'" } $_ = "hello" $_ = ' there' |
produces:
1 2 | $_ is now 'hello' $_ is now ' there' |
Please login to continue.