Skip to content

Instantly share code, notes, and snippets.

@epitron
Last active December 19, 2015 20:49
Show Gist options
  • Save epitron/6015603 to your computer and use it in GitHub Desktop.
Save epitron/6015603 to your computer and use it in GitHub Desktop.
Add bindings together!
class Binding
def +(other)
self.eval do
other.eval do
binding
end
end
end
end
def f
a = 1
binding
end
def g
b = 2
binding
end
if __FILE__ == $0
p (f + g).eval("a + b")
end
@kivikakk
Copy link

What Ruby is this legal in? 2.0p0 doesn't like Binding#eval without a (non-block) arg.

@epitron
Copy link
Author

epitron commented Jul 18, 2013

I wrote this a long time ago, so probably 1.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment