Skip to content

Instantly share code, notes, and snippets.

@boughtonp
Created September 26, 2012 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boughtonp/3788484 to your computer and use it in GitHub Desktop.
Save boughtonp/3788484 to your computer and use it in GitHub Desktop.
component
{
function init()
{
this.stuff = {'a a':'a','b b':'b','c c':'c'};
var keys = StructKeyList(this.stuff);
for (var i=1; i<=listLen(keys); i++)
{
var key = ListGetAt(keys,i);
this[key] = function() { return this.stuff[key]; }
}
return this;
}
}
<cfset tc = new test_closure() />
<cfset s1 = tc['a a'] />
<cfdump var=#s1()# />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment