Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Last active August 29, 2015 14:24
Show Gist options
  • Save jgaskins/9817fd2c653a0a6ae91f to your computer and use it in GitHub Desktop.
Save jgaskins/9817fd2c653a0a6ae91f to your computer and use it in GitHub Desktop.
Ruby proc vs lambda return
def proc_return(enum)
l = proc { |x| return x * 2 }
enum.map { |i| l[i] }
end
def lambda_return(enum)
l = lambda { |x| return x * 2 }
enum.map { |i| l[i] }
end
array = [1, 2, 3]
p proc_return(array) # => 2
p lambda_return(array) # => [2, 4, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment