DEV Community

Discussion on: The Dream of C# 9.0

Collapse
 
dudeinthemoon42 profile image
Bobby Barjasteh

Can the declarations inside those discriminated unions theoretically be inline functions? I know in your example you're providing the arguments and doing a little logic in the switch, i'm wondering if you could also do that kind of thing in the constructor. Maybe it wouldn't be helpful though. Cool article!

Collapse
 
integerman profile image
Matt Eland

Possibly. I couldn't find as many examples of working with Discriminated Unions in the feature proposal thread. I went with the switch expressions to try to get the syntax looking as close as F#'s Match expressions as possible while still working with existing C# syntax.