Skip to content

Instantly share code, notes, and snippets.

@pekhee
Created August 2, 2016 13:06
Show Gist options
  • Save pekhee/c2ed9e9076121adde43e2d64af1a1e52 to your computer and use it in GitHub Desktop.
Save pekhee/c2ed9e9076121adde43e2d64af1a1e52 to your computer and use it in GitHub Desktop.
Ruby blocks close their instance/class variable targets regardless of binding they are evaluated in.
class Foo
@@foo = :foo
end
class Example
@@foo = :example
Foo.define_singleton_method :foo do
@@foo
end
end
Foo.foo #=> :example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment