Skip to content

Instantly share code, notes, and snippets.

@santosh79
Created November 16, 2009 20:56
Show Gist options
  • Save santosh79/236308 to your computer and use it in GitHub Desktop.
Save santosh79/236308 to your computer and use it in GitHub Desktop.
#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