Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created September 13, 2015 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6fad0c1a62e7aa09120b to your computer and use it in GitHub Desktop.
Save anonymous/6fad0c1a62e7aa09120b to your computer and use it in GitHub Desktop.
### How is method(:bar) scoped in this case? (Within class A? Within class B? neither? Is the new B instance implicitly "self" within the do block?)
### The '@' in @var makes var an instance variable?
### A.new.foo returns a hash containing the key :key?
class A
def foo
@val = B.new do
{
key: method(:bar)
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment