declare type numOrString = string | number
union SearchResult = Human | Droid | Starship
type IntOrFloat {
AnInt(Int)
AFloat(Float)
}
fn int_or_float(x: IntOrFloat) {
case x {
AnInt(1) -> "It's an integer: 1"
AFloat(1.0) -> "It's a float: 1.0"
}
}
union Foo
{
int x;
float f;
struct
{
char[2] z;
}
}
Languages with Union Types include TypeScript, GraphQL, Gleam, C3, C2
View all concepts with or missing a hasUnionTypes measurement
Read more about Union Types on the web: 1.