Hacker News new | ask | show | jobs
by utf_8x 78 days ago
Hell yeah! After all these years it's finally here.

One thing I miss here (and admittedly I only skimmed through the post so if I missed this, please do correct me) is "ad hoc" unions.

It would be great to be able to do something like

  public Union<TypeA, TypeB> GetThing()...
Without having to declare the union first. Basically OneOf<...> but built-in and more integrated
1 comments

I guess you can define

  union Union<T1, T2>(T1, T2);
Add a bunch of overloads and you'd replicate for T1|T2 syntax the equivalent mess to (Value)Tuple<...> that eventually became the backing for actual tuple syntax.