Skip to content

Instantly share code, notes, and snippets.

@hanachin
Created February 22, 2018 06:04
Show Gist options
  • Save hanachin/63630afd72d5648ea7d05ba64f68f2c5 to your computer and use it in GitHub Desktop.
Save hanachin/63630afd72d5648ea7d05ba64f68f2c5 to your computer and use it in GitHub Desktop.
def f(x)
if x
unless x
p :foo
end
end
end
TracePoint.trace(:line) do |tp|
if tp.lineno == 2
tp.binding.local_variable_set(:x, true)
end
if tp.lineno == 3
tp.binding.local_variable_set(:x, false)
end
end
f("whatever")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment