Ruby: Proc.new {'waffles'} vs proc {' waffles}

In Ruby, are there differences between Proc.new { 'waffles' } and proc { 'waffles' } ? I have found very few references to the second syntax.

From testing with irb I did not find any obvious differences. Is second syntactic sugar first?

+27
syntax ruby
Jan 17 '11 at 6:28
source share
1 answer

From Metaprogamming Ruby Page 113.

In Ruby 1.8, the core of # proc () is actually a synonym for Kernel # lambda (). Due to loud protest from programmers, Ruby 1.9 made proc () a synonym for Proc.new () instead.

+40
Jan 17 '11 at 6:33
source share
— -



All Articles