Skip to content

Instantly share code, notes, and snippets.

@SaitoWu
Created March 17, 2011 14:44
Show Gist options
  • Save SaitoWu/874438 to your computer and use it in GitHub Desktop.
Save SaitoWu/874438 to your computer and use it in GitHub Desktop.
magic ruby proc demo
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