# the function must be defined in such a place
# ... so as to "catch" the binding of the vars ... cheesy
# otherwise we're stuck with the extra param
@_binding = binding
def write_pair(p, b = @_binding)
eval("
local_variables.each do |v|
if eval(v + \".object_id\") == " + p.object_id.to_s + "
puts v + ': ' + \"" + p.to_s + "\"
end
end
" , b)
end
a = 5
b = 6
username1 = "tyndall"
username = "tyndall"
username3 = "tyndall"
write_pair(username)
# username: tyndall