Skip to main content

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

Bookmark History

Saved by 12 people (-1 private), first by anonymouse user on 2006-03-02


Public Sticky notes

Closures have been around for a long time. I ran into them properly for the first time in Smalltalk where they're called Blocks. Lisp uses them heavily. They're also present in the Ruby scripting language - and are a major reason why many rubyists like using Ruby for scripting.

Highlighted by benxshen

In a language that has Closures, in this case Ruby, I'd write this.

def managers(emps)
  return emps.select {|e| e.isManager}
end

Highlighted by benxshen

Closures or Blocks

Highlighted by kenyth

Essentially a closure is a block of code that can be passed as an argument to a function call.

Highlighted by kenyth

a closure is a block of code that can be passed as an argument to a function call.

Highlighted by yorkjong

If the block of code takes any arguments you declare those between the vertical bars.

Highlighted by kenyth

Essentially select is a method defined on the Ruby collection class. It takes a block of code, a closure, as an argument.

Highlighted by yorkjong

closures can refer to variables visible at the time they were defined.

Highlighted by kenyth

closures can refer to variables visible at the time they were defined.

Highlighted by yorkjong

Java's anonymous inner classes can access locals - but only if they are final.

Highlighted by kenyth

the notation to use them is simple and clear.

Highlighted by kenyth

the first crucial point about closures is that they are a block of code plus the bindings to the environment they came from

Highlighted by yorkjong

a lot of blur about the exact definition of closure.

Highlighted by kenyth

Languages that support closures allow you to define them with very little syntax

Highlighted by yorkjong

File.open(filename) {|f| doSomethingWithFile(f)}

Highlighted by kenyth

Another common use is the 'execute around method', such as when processing a file.

File.open(filename) {|f| doSomethingWithFile(f)}

Highlighted by yorkjong