Created
May 7, 2015 20:50
-
-
Save ahirschberg/378904d1644976bdaf83 to your computer and use it in GitHub Desktop.
This file contains 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 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