C
C#11mo ago
niels

Complex question

Let's say I have a list of tuples. Now I also have a dictionary that maps from string to a subset of these tuples. Is it possible to, on compile time get hints for a specific string (which is a key from the dictionary) which tuples are included (without me having to go to the source code and look into the mapping)?
2 Replies
Sossenbinder
Sossenbinder11mo ago
Not really, I think what you describe is meant to be a runtime construct, and in that regard, no It would have to be backed by the type system I imagine your question would relate to something like a Discriminated Union of types which would be able to infer the result type based on guard clauses, like e.g. TypeScript can I think what you can get though would be something like a switch expression so you can at least get code navigation to help you out
AdmSnyder
AdmSnyder11mo ago
instead of using a string, you could use an enum. or use a string constant - you can then put xml comments in there telling you what they mean. but you would have to write those xml comments, right? ... or let them be generated?

Did you find this page helpful?