Skip to content

Instantly share code, notes, and snippets.

@apeiros
Created April 21, 2010 10:12
Show Gist options
  • Save apeiros/373654 to your computer and use it in GitHub Desktop.
Save apeiros/373654 to your computer and use it in GitHub Desktop.
# If you like f'ing around with people using your code, you can do
def stupid(arg, newval, b)
lvars = eval("local_variables",b)
relevant = lvars.find { |lvar| eval(lvar, b).equal?(arg) }
Thread.current[:stupid] = newval
relevant.each do |lvar| eval("#{lvar} = Thread.current[:stupid]", b) end
end
a = 1
stupid(a, 2, binding)
p a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment