More Ruby from the Queen of Code!!

here you go…this one took me for-freaking-ever to write!!

this program simulates a method calling three nested blocks..so the outer block starts, then a small one and another smaller one. The program tells you when each block starts and finishes running!

I need a break!!

def logger someProc
someProc.call
end

smaller = Proc.new do
puts “b3den?”
end

small = Proc.new do
puts “hi”
puts “smaller block started”
logger smaller
puts “smaller block ended”
end

outer = Proc.new do
puts “outer block started”
puts “hello”
puts “small block started”
logger small
puts “small block ended”
puts “outer block ended”
end

logger outer

Advertisements