4 ms·
You want to return different types depending on the branch? I mean you could return a sum type if you really need to. Formally a sum type is just something th
by shiandow 1y ago
You want to return different types depending on the branch?
I mean you could return a sum type if you really need to.
Formally a sum type is just something that turns a pair of functions to Z into a single function from the sum type to Z. In fact it shouldn't do more than that.
- masfuerte 1y agoNo, in any particular use of the value both branches return the same type Z. But when I want to use the value in two different places I don't want Z to be the same in both places. That's where I'm stuck. When I instantiate the function that represents a value of the sum type I need to choose a return type Z, which is locked in for every use of the value. I think I understand the idea. I don't see how to make it work in C#.