Generating and Understanding Tracebacks : caller « Reflection « Ruby






Generating and Understanding Tracebacks



/usr/bin/ruby                                                  

                                                               
def do_work
  first = true                                                 
  caller.each do |c|                                           
    puts %{#{(first ? 'I' : ' which')} was called by "#{c}"}   
    first = false                                              
  end                                                          
end                                                            

do_work

 








Related examples in the same category

1.Get caller line number