Keeping it simple:
def test
puts 'before'
yield 2
puts 'after'
end
test do |i|
unless i > 1
puts "a lot of code here"
end
end
There's also throw/catch:
test do |i|
catch(:done) do
throw(:done) if i > 1
puts "a lot of code here"
end
end
--
Posted via http://www.ruby-forum.com/.