Languages Features Calendar About Lists Add Language
GitHub icon

Union Types

Union Types

Union Types are a language feature.

In computer science, a union is a value that may have any of several representations or formats within the same position in memory; that consists of a variable that may hold such a data structure. Some programming languages support special data types, called union types, to describe such values and variables. In other words, a union type definition will specify which of a number of permitted primitive types may be stored in its instances, e.g., "float or long integer". Read more on Wikipedia...

Languages with Union Types include TypeScript, GraphQL

Example from TypeScript:

declare type numOrString = string | number

Example from GraphQL:

union SearchResult = Human | Droid | Starship

Article source

PLDB - Build the next great programming language 路 v2022 Docs Acknowledgements Email GitHub