Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Current »


Martin Fowler has a good introduction to closures on his bliki.


There are two syntaxes for closures: a block based syntax with syntactically significant whitespace and a braces based that ignores whitespace.

Block based syntax

Braces based


Boo closures have have full access (to read and write) to their enclosing lexical environment. For Instance:

The best source of information right now are the test cases for closures in the tests/testcases/integration directory.

Closures vs. Functions

See Functions As Objects.

Some things you can do with named functions that you cannot with closures include recursion and overloading:

This will not work because "c" is unknown from inside the closure:

so you can use a regular named function or else create a 2nd callable to hold the name:

And you can use regular named functions to overload a method:

See Also

Functions, Parameters, Callable Types, Events

  • No labels