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.
–
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:[email protected]
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3
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@:3(irb)
irb(main):006:0> fun.call
=> []
irb(main):007:0> a
=> []
Yeah, I thought that lambdas supported closures, so they hold their
state
and you can pass it around.
-Corey