logoalt Hacker News

_old_dude_today at 12:41 PM1 replyview on HN

In C#, all instances have a class, so there is already a discriminant, the class itself.

In the article, the example with the switch works because it switches on the class of the instance.


Replies

cobbaltoday at 6:24 PM

Null doesn't. `union(Int?, String?)` will only have 1 type of null, unlike a proper discriminated union.

show 1 reply