dotnet / dotnet/csharplang

Champion "conditional ref operator" (C# 7.2)

Open
#223 17 comments 25 reactions 1 assignee Assigned to @jaredpar View on GitHub
Implemented Needs ECMA Spec Proposal champion
Dominant language
C#
Stars
12.7k
Forks
1.1k
Avg merge
11h 1m
Merged PRs (30d)
3

Description

- [x] Proposal added
(https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.2/conditional-ref.md)
- [x] Discussed in LDM
- [x] Decision in LDM
- [x] Finalized (done, rejected, inactive)
- [ ] Spec'ed

See also
- https://github.com/dotnet/roslyn/issues/16473 (original spec)
- https://github.com/dotnet/roslyn/pull/17436 (prototype)
- The most up-to-date description of the feature (as implemented in C# 7.2) is a part of the following document:
https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.2/readonly-ref.md

The idea would be to support a version of the `?:` operator that yields an lvalue. The current proposal is to do so using `ref` after the `:` and `?`, for example

``` c#
(array1 != null ? ref array1[index] : ref dummy) = value;
```

``` c#
ref Node next = ref (node != null) ? ref node.Next : ref head;
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.