4 ms·
This is not equivalent. It will result in y if x is any falsy value (like false, empty string, or 0), not just if x is nullish.
by rimunroe 7y ago
This is not equivalent. It will result in y if x is any falsy value (like false, empty string, or 0), not just if x is nullish.
- jchook 7y agoIn which languages does ?: not work that way? For example in PHP, it works exactly like you describe.
- nojvek 7y agoI think that’s exactly what the nullish ?? Operator is. You can write x ?? y Which is x !== null and x != undefined ? x : y
- james-mcelwain 7y agoKotlin.