Linked by Eugenia Loli on Thu 18th Jan 2007 00:27 UTC
General Development The Java community has resisted closures so far, even as competing languages such as C# add them. Closures are anonymous functions with closed scope. It's best to think of a closure as a code block that you can use as an argument, with special scoping rules. This article dives deep into Closures and uses Ruby to show how closures work.
Permalink for comment 203395
To read all comments associated with this story, please click here.
RE[3]: bleh
by leavengood on Fri 19th Jan 2007 06:27 UTC in reply to "RE[2]: bleh"
leavengood
Member since:
2006-12-13

"By the way Ruby code blocks are also not closures..."

Yeah they are:

irb(main):001:0> def make_proc(x)
irb(main):002:1> y = 3
irb(main):003:1> return proc { x + y }
irb(main):004:1> end
=> nil
irb(main):005:0> p = make_proc(2)
=> #<Proc:0x02c18da4@(irb):3>
irb(main):006:0> p[]
=> 5

Edited 2007-01-19 06:28

Reply Parent Score: 2