Skip to content

Algrebaic Data Type

Published: at 07:48 AM

In programming, especially functional programming, algrebaic data type is kind of type that is composed from other types. In #Swift we have enum and struct as algrebaic data types.

Enum is sum types. While we can have multiple options in a enum as cases, but when defined as variable, we only hold one of its case.

Struct is product types. Think of it as a blueprint that can hold multiple properties with different types.

References: