Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nullish coalescing operator ?? in mathjs expression language #3353

Open
gwhitney opened this issue Jan 18, 2025 · 0 comments
Open

Support nullish coalescing operator ?? in mathjs expression language #3353

gwhitney opened this issue Jan 18, 2025 · 0 comments
Labels
category:expressions Issues about the expression parser, variable scoping etc. feature

Comments

@gwhitney
Copy link
Collaborator

Describe the suggested feature
Currently x ?? 0 is a syntax error. It would be handy if this meant the nullish coalescing operator denoted by ?? in JavaScript. For example, one could then do object lookup with a fallback : {foo: 7, bar: 3}["baz"] ?? 0.

Current workaround
nullish(x, y) = (x == null or x == undefined) ? y : x; nullish(null, 0)

I am not aware of a short way to test for null or undefined unlike x == null in JavaScript which is true if x is either null or undefined; in mathjs expression language it is true when x is null and false when x is undefined.

@gwhitney gwhitney added category:expressions Issues about the expression parser, variable scoping etc. feature labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:expressions Issues about the expression parser, variable scoping etc. feature
Projects
None yet
Development

No branches or pull requests

1 participant