Created
November 5, 2014 10:28
-
-
Save ebouchut/de985c784be328694098 to your computer and use it in GitHub Desktop.
Convert a block into a Proc in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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