Replies: 2 comments
-
The problem with that approach is that the CLR treats generic types as unique based on their arity of generic type parameters, so |
Beta Was this translation helpful? Give feedback.
-
And if Repo class declaration would be something like this?
This could say to CLR that type is a For avoid ambiguity, I could also choose a keyword for autocomplete the field, or simply leave it empty like this:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm not sure that this had not been discussed, but from a rapid search I didn't find this proposal.
I've code like this:
In my Repo class, I need to access both the
TModel
andTKey
, but when I specific theTModel
argument, a pattern matching system should be able to extract theTKey
automatically.For use the
TKey
generic type, I have to declare it as a generic argument, so every time that I need to create a Repo, I have to specific model and relative key types.My propose is to implement generic type inference from
where
constructs, soTKey
could be removed from class declaration, and Repo could be written like this:Beta Was this translation helpful? Give feedback.
All reactions