Skip to content

Instantly share code, notes, and snippets.

@p886
Created August 21, 2014 11:19
Show Gist options
  • Save p886/0dc3d4807c764f116775 to your computer and use it in GitHub Desktop.
Save p886/0dc3d4807c764f116775 to your computer and use it in GitHub Desktop.
Ruby to_proc Example
def say(a_proc_obj)
a_proc_obj.call
end
def tell
yield
end
a_lambda = -> { puts "there you go" }
# both will output "there you go"
say(a_lambda)
# ampersand implies Proc object. Ruby takes it from the parameter list and converts it into a block
tell(&a_lambda)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment