Created
November 16, 2009 20:56
-
-
Save santosh79/236308 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
#When a proc calls a return - it returns from the context | |
def method | |
puts "at top of method" | |
p = Proc.new { return } | |
p.call | |
puts "at bottom of method" | |
end | |
puts "before call" | |
method | |
puts "after call" | |
#The *at bottom of method* is NOT going to be printed | |
#When a lamba returns - it just returns from itself | |
def method | |
puts "at top of method" | |
p = lambda { return } | |
p.call | |
puts "at bottom of method" | |
end | |
puts "before call" | |
method | |
puts "after call" | |
#The *at bottom of method* WILL be printed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment