[Proposal]: Conditional operator/access syntax refinement
- Dominant language
- C#
- Stars
- 12.7k
- Forks
- 1.1k
- Avg merge
- 11h 1m
- Merged PRs (30d)
- 3
Description
# Conditional-expression/access syntax refinement.
* Specification: https://github.com/dotnet/csharplang/blob/main/proposals/conditional-operator-access-syntax-refinement.md
* Discussion: https://github.com/dotnet/csharplang/discussions/9780
## Summary
[summary]: #summary
Introduce whitespace-sensitive parsing rules to eliminate ambiguity between the conditional operator (`?:`)
and null-conditional access operators (`?.` and `?[`). This change requires that tokens in null-conditional
operators must be adjacent with no intervening characters, while conditional operators with certain operand
patterns must have whitespace or comments between the `?` and the subsequent token.
For example: `a?[` will always be interpreted to be the start of a conditional index into `a` (e.g. `a?[b]`). In other words, indexing into `a` with some arguments that follow the `[` if `a` is non-null. Whereas `a? [` will always be interpreted to be the start of a condition expression (e.g. `a ? [b] : ...`). So a test if `a` is true or not, and returning a collection expression if so.
## Design meetings
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.