PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Union Types

Union Types

Union Types are a 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
variadic-functions-feature.html 路 union-types-feature.html 路 lists-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 28 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub feedback@pldb.com