RATools
RATools copied to clipboard
Cannot use anonymous predicate as default function argument ("Default value for pred is not constant")
The following code:
function foo(pred=(v) => v)
{
return always_true()
}
will create the error Default value for pred is not constant
.
However, the following code:
_ = v => v
function foo(pred=_)
{
return always_true()
}
will compile without error.
This issue seems to suggest that any anonymous predicates cannot be used as default function arguments, whereas there's no technical reason why that shouldn't be the case.