From: Josh Cheek Date: 2010-11-27T12:50:12+09:00 Subject: Re: Newbie: two cool discoveries --0016368325ac58a94d049600bc68 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Nov 26, 2010 at 6:45 PM, w_a_x_man wrote: > On Nov 26, 8:11 am, Arturo Garcia wrote: > > the "&" is a shortcut to "to_proc" > > > > class Symbol > > def to_proc > > lambda { |x| x.__send__(self) } > > Note that it's to_proc, not to_lambda. I don't see why > anyone would want to type the gibberish "lambda" when > he could type the shorter and clearer "proc". > > Because lambda is more pretentious (at least, thats why I use it) They actually have different meanings, though (sometimes) $ cat proc_vs_lambda.rb def invoke_lambda lambda { return 1 }.call return 2 end def invoke_proc proc { return 1 }.call return 2 end require 'pp' puts ENV['RUBY_VERSION'] puts invoke_lambda # => 2 puts invoke_proc # => 1 puts $ rvm proc_vs_lambda.rb jruby-1.5.3 2 2 macruby-0.7 2 1 rbx-1.1.0-20100923 2 2 ruby-1.8.6-p399 2 2 ruby-1.8.7-p302 2 2 ruby-1.9.1-p378 2 1 ruby-1.9.2-p0 2 1 --0016368325ac58a94d049600bc68--