Skip to content

Instantly share code, notes, and snippets.

@ahirschberg
Created May 7, 2015 20:50
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 ahirschberg/378904d1644976bdaf83 to your computer and use it in GitHub Desktop.
Save ahirschberg/378904d1644976bdaf83 to your computer and use it in GitHub Desktop.
class TestClass
def test_scope
times_called = 0
other_func do # passes block into #other_func
times_called += 1
end
puts "Called #{times_called} times"
end
end
def other_func(&callback)
(1..5).each do
callback.call
end
end
tc = TestClass.new
tc.test_scope #=> Called 5 times
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment