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 <[EMAIL PROTECTED]> wrote:

> On Jan 29, 2008 8:48 PM, James B. Byrne <[EMAIL PROTECTED]> wrote:
> > Message-ID:<[EMAIL PROTECTED]>
> >
> > On: Tue, 29 Jan 2008 20:47:41 -0500, "Andrew WC Brown" <
> [EMAIL PROTECTED]>
> > 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@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



-- 
http://www.coreyhaines.com
The Internet's Premiere source of information about Corey Haines
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to