Yeah, I thought that lambdas supported closures, so they hold their state
and you can pass it around.
-Corey
On Jan 29, 2008 11:55 PM, Pat Maddox <pergesu at gmail.com> wrote:
> On Jan 29, 2008 8:48 PM, James B. Byrne <byrnejb at harte-lyne.ca>
wrote:
> > Message-ID:<ef1d468f0801291747q3f605e6cjb73028a888a441ee at
mail.gmail.com>
> >
> > On: Tue, 29 Jan 2008 20:47:41 -0500, "Andrew WC Brown" <
> omen.king at gmail.com>
> > wrote:
> >
> > > I''ve seen lambda before but not sure what it does.
> >
> > A lambda is a fancy name for an anonymous or unbound function. Its
> > significance comes from the fact that it is completely stateless,
> producing no
> > side effects to its returned result.
>
> I don''t know about that...
>
> irb(main):001:0> a = [1,2,3]
> => [1, 2, 3]
> irb(main):002:0> def foo(array)
> irb(main):003:1> lambda { array.clear }
> irb(main):004:1> end
> => nil
> irb(main):005:0> fun = foo a
> => #<Proc:0x002842a4@(irb):3>
> irb(main):006:0> fun.call
> => []
> irb(main):007:0> a
> => []
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
--
http://www.coreyhaines.com
The Internet''s Premiere source of information about Corey Haines
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/rspec-users/attachments/20080130/b2f20a87/attachment.html