Is it possible to see the ruby code in a proc?
问题 p = Proc.new{ puts 'ok' } Is is possible to see the ruby code in the proc? inspect returns the memory location: puts p.inspect #<Proc:0x007f9e42980b88@(irb):2> Ruby 1.9.3 回答1: Take a look at the sourcify gem: proc { x + y }.to_source # >> "proc { (x + y) }" 回答2: Do you mean the original source code or its bytecode representation ? For the former you may use standard Proc's method source_location p.source_location => ["test.rb", 21] and read the appropriate lines of code. For the latter it may