Created
August 2, 2016 13:06
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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