Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood ()
Created: 03/10/2017
Components: Language, Closures
Versions: 2016,11.0,10.0
Failure Type: Enhancement Request
Found In Build/Fixed In Build: / CF2018U5
Priority/Frequency: Normal /
Locale/System: /
Vote Count: 16
Please support the popular "arrow function" syntax for declaring closures. Please copy the precedent already set by Lucee Server. This is documented here:
http://docs.lucee.org/guides/lucee-5/lambda.html
It basically works like this:
Simple lambda with no arguments
{code:java}
// Using a traditional function
makeSix = function() { return 5 + 1; }
// Using a lambda expression
makeSix = () => 5 + 1;
Simple lambda with arguments:
// Takes two numeric values and adds them
add = (numeric x, numeric y) => x + y;
Another example with an argument:
// Takes a numeric value and returns a string
isOdd = (numeric n) => {
if ( n % 2 == 0 ) {
return 'even';
} else {
return 'odd';
}
};
{code}
Attachments:
Comments: