Created
December 3, 2012 02:05
-
-
Save johntdyer/4192150 to your computer and use it in GitHub Desktop.
BLock Test
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
#!/usr/bin/env ruby | |
def yield_noargs | |
puts "hi from yield_noargs" | |
yield if block_given? | |
end | |
def yield_args(foo) | |
puts "hi from yield_args" | |
puts "Was pased #{foo}" | |
yield if block_given? | |
end | |
def proc_onearg(&p) | |
puts "hi from proc_onearg" | |
p.call | |
end | |
def proc_twoarg(foo, &p) | |
puts "hi from proc_onearg" | |
puts "Was pased #{foo}" | |
p.call | |
end | |
yield_noargs | |
yield_noargs {puts "hi from the block"} | |
yield_args "foo" | |
# this has syntax error | |
# yield_args "foo", {puts "the block"} | |
proc_onearg {puts "hi from the block"} | |
# this has syntax error | |
# proc_twoarg "foo", {puts "hi from the block"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment