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
Optional Chaining doesn't work for Out-of-range array indexes #540
Comments
In JS Not sure what is the best solution here. |
Expr for this purpose have a special builtin function get(array, index). It will return nil instead of raised error:
|
Another solution I'm looking into is adding an option to Expr to make all |
But this would get bulky very fast wouldn't it?
I would love that! |
I agree. Let's make an option to set all MemberNodes as optional.
Make array access should return nil instead of rasing error by default. And have an option like expr.PanicOnOutOfBound(). |
Love it |
What
Using the Playground with the newest version 1.16 I expected
Posts[10]?.Title
to result in undefined whereas it throwsJust like in JS
[][1]?.a
also works and yields null/undefined making things like[][1]?.a ?? 42
work where asPosts[10]?.Title ?? "default"
does not work currently in with this library.Or is this expected/deliberate?
The text was updated successfully, but these errors were encountered: