Skip to content

Instantly share code, notes, and snippets.

@ebouchut
Created November 5, 2014 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebouchut/de985c784be328694098 to your computer and use it in GitHub Desktop.
Save ebouchut/de985c784be328694098 to your computer and use it in GitHub Desktop.
Convert a block into a Proc in Ruby
def convert_to_proc(&proc)
proc
end
hello = convert_to_proc { |name| puts "Hello #{name}" }
hello.call("Eric") # => "Hello Eric"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment