tink_anon
tink_anon copied to clipboard
Merge fails to recognise condition in expr
This does not work:
var a = {v: "none"};
function getResult(isYes:Bool)
return tink.Anon.merge(a, isYes ? {v:"it works"} : {});
trace(getResult(true));
trace(getResult(false));
OTOH this works:
tink.Anon.merge(a, {v: isYes ? "it works" : ""});
I believe it is not trivial thing to fix (if even possible) so adding a compilation error and a notion to readme about this kinds of limitation would be useful.
I think the readme has clearly stated that the function takes expressions and the supported expressions are already listed.
This falls into the third case and the reason of your problem can be revealed by a $type print:
$type(isYes ? {v:"it works"} : {}); // {}
i.e. no fields will get merged from this expression