M
michelemendel
Why does the following code print the line "doing other stuff" twice?
def cc
puts "do A"
puts "----> 1. #{caller}"
callcc { |cont| return cont}
puts "----> 2. #{caller}"
puts "do B"
end
puts "calling cc"
cont = cc()
puts "doing other stuff"
cont.call() if cont
puts "end of work"
puts
OUTPUT:
calling cc
do A
----> 1. remove2.rb:59
doing other stuff
----> 2. remove2.rb:59
do B
doing other stuff
end of work
def cc
puts "do A"
puts "----> 1. #{caller}"
callcc { |cont| return cont}
puts "----> 2. #{caller}"
puts "do B"
end
puts "calling cc"
cont = cc()
puts "doing other stuff"
cont.call() if cont
puts "end of work"
puts
OUTPUT:
calling cc
do A
----> 1. remove2.rb:59
doing other stuff
----> 2. remove2.rb:59
do B
doing other stuff
end of work