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

Deep nil coalescing ?? #573

Open
antonmedv opened this issue Feb 20, 2024 · 3 comments
Open

Deep nil coalescing ?? #573

antonmedv opened this issue Feb 20, 2024 · 3 comments
Labels

Comments

@antonmedv
Copy link
Member

Right now, in order to use ?? user have to use ?. instead of . in nested structures.

events[0]?.labels?.value ?? 'defaul'

My idea is to make left hand side of ?? optional by default. So in case user written:

events[0].labels.value ?? 'defaul'

All member accesses to label/value/events will be optional. As well as array element access.

I really like this idea and think it makes much sense.

@antonmedv
Copy link
Member Author

Also implement opcode to do chained optional fetch

@antonmedv antonmedv changed the title Deep nil coalescing Deep nil coalescing ?? Feb 21, 2024
@ckganesan
Copy link
Contributor

ckganesan commented Feb 22, 2024

@antonmedv : I have addressed these issues in the pull request. Could you please review this PR #583

@antonmedv
Copy link
Member Author

Cool! Will take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants