Created
March 17, 2011 14:44
-
-
Save SaitoWu/874438 to your computer and use it in GitHub Desktop.
magic ruby proc demo
This file contains 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 block_new | |
puts Proc.new.call | |
end | |
block_new{"hello"} | |
#slow practice | |
def herp_pass_block(&block) | |
derp_call_block &block | |
end | |
def derp_call_block | |
puts yield | |
end | |
herp_pass_block{"!"} | |
#better one 10 times speed | |
def pass_block | |
call_block &Proc.new | |
end | |
def call_block | |
puts yield | |
end | |
pass_block{"world"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment