Mega Code Archive

 
Categories / Ruby / Method
 

Contain two yields, then call it with a block It executes the block twice

def gimme   if block_given?     yield     yield   else     puts "I'm blockless!"   end end gimme { print "Say hi again. " } # => Say hi again. Say hi again.