Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@twoism-dev
Created February 7, 2013 10:34
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 twoism-dev/4730151 to your computer and use it in GitHub Desktop.
Save twoism-dev/4730151 to your computer and use it in GitHub Desktop.
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
Copy link
Author

tesr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment