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