Skip to content

Instantly share code, notes, and snippets.

@luckydev
Created August 14, 2011 05:38
Show Gist options
  • Save luckydev/1144620 to your computer and use it in GitHub Desktop.
Save luckydev/1144620 to your computer and use it in GitHub Desktop.
Proc and Lambda: Difference 1 - Return policy
def my_awesome_method
ret = lambda { return "This is returned from Lambda" }
ret.call
"This line will run"
end
puts my_awesome_method
# => "This is returned from Lambda"
# => "This line will run"
def my_awesome_method
ret = Proc.new { return "This is returned from Proc" }
ret.call
"I won't be executed if Proc is returning above me"
end
puts my_awesome_method
# => "This is returned from Proc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment