Expression closures - use-cases for shortcut lambda syntax (blocks)

Chris Pine chrispi at opera.com
Tue Mar 20 13:30:25 PDT 2007


> On 17/03/07, Vassily Gavrilyak <gavrilyak at gmail.com> wrote:
>> File.open("file.txt") do  | file
>>    file.process()
>> end

Should be:
   File.open("file.txt") do |file| ... end

On Sat, 17 Mar 2007 02:37:13 +0100, Igor Bukanov <igor at mir2.org> wrote:
> Ruby's do construction is also a loop, not a lambda

Not true at all; it's every bit a lambda and not at all a loop.  The above  
is the same as:

   file_func = lambda {file.process()}

   File.open("file.txt", &file_func)

Not really all that relevant, but just couldn't let it pass.  :)

Chris



More information about the Es4-discuss mailing list