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

Proposal: ?= lazy initialization operator #4374

Closed
Andriy-Gorbunov opened this issue Aug 6, 2015 · 2 comments
Closed

Proposal: ?= lazy initialization operator #4374

Andriy-Gorbunov opened this issue Aug 6, 2015 · 2 comments

Comments

@Andriy-Gorbunov
Copy link

Replace the typical construction
{ return _variable ?? (_variable = new Instance()); }
with
{ return _variable ?= new Instance(); }
This also can be atomical, i. e. prevent double calculating of the right side if two threads try accessing the field at once.

@khellang
Copy link
Member

khellang commented Aug 6, 2015

Related to #3415, #3630, #524 and #3251

@gafter
Copy link
Member

gafter commented Mar 20, 2017

We are now taking language feature discussion on https://github.com/dotnet/csharplang for C# specific issues, https://github.com/dotnet/vblang for VB-specific features, and https://github.com/dotnet/csharplang for features that affect both languages.

@gafter gafter closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants