-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Dictionary expressions: update key-value pair conversions #8850
base: main
Are you sure you want to change the base?
Conversation
> * If `Eᵢ` is a *key value pair element* `Kᵢ:Vᵢ`, there is an implicit conversion from `Kᵢ` to `K` and an implicit conversion from `Vᵢ` to `V`. | ||
> * If `Eᵢ` is a *spread element* `..Sᵢ`, then the *iteration type* of `Sᵢ` is `KeyValuePair<Kᵢ:Vᵢ>` and there is an implicit conversion from `Kᵢ` to `K` and an implicit conversion from `Vᵢ` to `V`. | ||
> * Otherwise there is *no implicit conversion* from the collection expression to the target type. | ||
An explicit *key-value pair conversion* exists from an expression of type `KeyValuePair<T1, T2>` to a type `KeyValuePair<U1, U2>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the explicit conversion matter for us? Or is now for parity/completeness with existing conversions?
Trying to figure out how it would matter for CEs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explicit conversion is for completeness and consistency with other conversions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good :)
proposals/dictionary-expressions.md
Outdated
``` | ||
|
||
Key-value pair conversions are similar to *tuple conversions* that allow converting between distinct tuple types. | ||
That said, a tuple conversion is [*defined*](https://github.com/dotnet/csharpstandard/blob/draft-v8/standard/conversions.md#10213-implicit-tuple-conversions) as a conversion from a *tuple expression* rather than a tuple type, despite being allowed in conversions like `b = a` below, so perhaps conversions between `KeyValuePair<,>` *types* should not be supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See csharpstandard/issues 1155
No description provided.