Skip to content

[Proposal]: Standard Unions #9565

@mattwar

Description

@mattwar

Standard Unions

Summary

A family of nominal type unions exist in the TBD namespace that can be used across assemblies as the standard way to specify a type union without needing to declare and name one.

public union Union<T1, T2>(T1, T2);
public union Union<T1, T2, T3>(T1, T2, T3);
public union Union<T1, T2, T3, T4>(T1, T2, T3, T4);
...

Union<int, string> x = 10;
...
var _ = x switch 
{
    int v => ...,
    string v => ...
}

Design meetings

#9571

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions