|
||||||
|
||||||
Closures
IntroductionMartin Fowler has a good introduction to closures on his bliki. SyntaxThere are two syntaxes for closures: a block based syntax with syntactically significant whitespace and a braces based that ignores whitespace. Block based syntaxBraces basedSemanticsBoo 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. FunctionsSee 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 |
||||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
||||||