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]: Null conditional assignment #8677

Open
RikkiGibson opened this issue Nov 22, 2024 · 0 comments
Open

[Proposal]: Null conditional assignment #8677

RikkiGibson opened this issue Nov 22, 2024 · 0 comments

Comments

@RikkiGibson
Copy link
Contributor

Summary

Permits assignment to occur conditionally within a a?.b or a?[b] expression.

using System;

class C
{
    public object obj;
}

void M(C? c)
{
    c?.obj = new object();
}
using System;

class C
{
    public event Action E;
}

void M(C? c)
{
    c?.E += () => { Console.WriteLine("handled event E"); };
}
void M(object[]? arr)
{
    arr?[42] = new object();
}

Design meetings

@RikkiGibson RikkiGibson self-assigned this Nov 22, 2024
@dotnet dotnet locked and limited conversation to collaborators Nov 22, 2024
@RikkiGibson RikkiGibson added this to the Working Set milestone Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant