Compare the Content, Not the Results, of Procs

后端 未结 2 508
后悔当初
后悔当初 2021-01-13 18:32

Using Ruby 1.9.2

Problem
Compare the content, not the results, of two procs. I understand the results can\'t be tested because

2条回答
  •  耶瑟儿~
    2021-01-13 18:47

    If you're using Ruby 1.9, you may be able to use the sourcify gem.

    $ irb
    > require 'sourcify'
    => true 
    > a = proc {@x == "x"}
    => # 
    > b = proc {@x == %{x}}
    => # 
    > a == b
    => false 
    > a.to_source == b.to_source
    => true 
    > RUBY_VERSION
    => "1.9.2" 
    

    We also ran into the ParseTree/Ruby 1.9 incompatibility problem at my company.

提交回复
热议问题