I just ran across a template that had an interesting typo. Here is an example.
component {
{
public function hello() {
return "Hello";
}
}
}
See it? The function is surrounded by an extra pair of brackets. ColdFusion just hoists it up just like JavaScript, so I shouldn't be surprised, but wow did that freak me out a bit.
Then for the hell of it I went crazy - and yes - it still works.
component {
{
{
{
{
{
public function hello() {
return "Hello";
}
}
}
}
}
}
}
Anyway... yeah... don't do this. ;)
Archived Comments
It basically creates a closure. You can use namespacing like you would in javascript as well.
https://gist.github.com/dfg...
I'm not sure I agree with you. By itself the extra {} aren't making a closure - not in the example above. In yours you are when you *specifically* return the function, but by *itself*, as in the code above caused by a mistake on the dev's part, it isn't a closure.
Right?
It's just extra parentheses, it does not cause the function to use closure. Let me gist... https://gist.github.com/dac...
--
Adam
(was tempted to post all the code here, as I know how much you like that, Ray ;-)