Algebraic data types can be composite types with variants as well. We could create an enum named Dimension to hold the length and width. We can express this enum in both us feet and metric meters. In Swift, we can define such an enum as follows:
enum Dimension {
case us(Double, Double)
case metric(Double, Double)
}
Then we can use the Dimension enumeration to create a variable as follows:
let sizeMetric = Dimension.metric(5.0, 4.0)