Advertisement
Guest User

Ruby syntax scoping question

a guest
Sep 13th, 2015
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.36 KB | None | 0 0
  1. ### 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?)
  2. ### The '@' in @var makes var an instance variable?
  3. ### A.new.foo returns a hash containing the key :key?
  4.  
  5. class A
  6.   def foo
  7.     @val = B.new do
  8.       {
  9.         key: method(:bar)
  10.       }
  11.     end
  12.  end
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement