Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A demo of how block returns.
class Tester
@@blocks = []
def self.add(&block)
@@blocks << block
end
def self.run
@@blocks.each_with_index do |block, n|
exec(n)
end
end
def self.exec(n)
@@blocks[n].call
end
end
def test
Tester.add do
puts 'block 1'
return 1
end
Tester.add do
puts 'block 2'
end
Tester.run
end
test
@twoism-dev

This comment has been minimized.

Copy link
Owner Author

twoism-dev commented Jun 17, 2014

tesr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.