Ruby: Proc#call vs yield

后端 未结 6 1480
野性不改
野性不改 2020-12-02 05:54

What are the behavioural differences between the following two implementations in Ruby of the thrice method?

module WithYield
  def self.thrice
         


        
6条回答
  •  忘掉有多难
    2020-12-02 06:17

    BTW, just to update this to current day using:

    ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
    

    On Intel i7 (1.5 years oldish).

    user     system      total        real
    0.010000   0.000000   0.010000 (  0.015555)
    0.030000   0.000000   0.030000 (  0.024416)
    0.120000   0.000000   0.120000 (  0.121450)
    0.240000   0.000000   0.240000 (  0.239760)
    

    Still 2x slower. Interesting.

提交回复
热议问题