Is it possible to see the ruby code in a proc?

后端 未结 5 1006
别那么骄傲
别那么骄傲 2021-02-05 15:52
p = Proc.new{ puts \'ok\' }

Is is possible to see the ruby code in the proc?

inspect returns the memory location:

         


        
5条回答
  •  时光说笑
    2021-02-05 16:36

    Take a look at the sourcify gem:

    proc { x + y }.to_source
    # >> "proc { (x + y) }"
    

提交回复
热议问题