Skip to content

Instantly share code, notes, and snippets.

@songpp
Created April 2, 2011 07:56
Show Gist options
  • Save songpp/899319 to your computer and use it in GitHub Desktop.
Save songpp/899319 to your computer and use it in GitHub Desktop.
ruby block given ?
def t1(ar1,ar2,&block)
if(block_given?)
yield(ar1,ar2)
else
puts ar1 , ar2
end
block.call(ar1,ar2)
end
t1(1,2)do|f,s|
puts "first #{f} + second #{s}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment