I'm having problems defining a lambda function that takes an optional parameter. The strange part is that if I use the full syntax of the βfunctionβ, the anonymous function works, but the lambda shortcut / arrow syntax causes errors like the following:
- The name 'a' does not exist in the current scope
- The supplied parameters do not match any target call signature
- Expected ')'
Example:
(function (a, b?) => { console.log(a, b); })("a"); // OK ((a, b?) => { console.log(a, b); })("a", "b"); // Errors ((a, b) => { console.log(a, b); })("a", "b"); // OK
source share