[rspec-users] (no subject)

Pat Maddox pergesu at gmail.com
Tue Jan 29 23:55:10 EST 2008


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
=> []


More information about the rspec-users mailing list