Created
May 30, 2010 15:31
-
-
Save unnu/419105 to your computer and use it in GitHub Desktop.
next can be used tor return from a block with return value in Ruby
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
def foo | |
2.times do |i| | |
puts yield | |
puts "We will go here #{i}" | |
end | |
end | |
foo do | |
next "Next is the block's return" | |
"Never returns this" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment