ruby - proc return vs lambda return -


why proc in ruby return before executing remaining codes in method proc called?

def hello   = proc.new{ return }   a.call   puts "hello" end   def proc   hello   puts "proc" end 

here return skip puts "hello" , prints puts "proc"

but lambda prints puts "hello" well.

what's reason this?

you should see comment in answer https://stackoverflow.com/a/723/4576274.

it states

a lambda anonymous method. since it's method, returns value, , method called can whatever wants, including ignoring , returning different value.

a proc pasting in code snippet. doesn't act method. when return happens within proc, that's part of code of method called it


Comments