▲ | duckfan77 3 days ago | |
The number of valid options is the sum of the valid option for each variant. This is also why product types are called product types. If you have a struct (product type) containing an 8 bit integer and a boolean, the struct has 512 possible states. 256 for the integer, times 2 for each value of the boolean. If you have a sum type where one variant is an 8 bit integer, and the other is a boolean, you have 258 possible states. 256 for when it's an integer, and 2 for when it's a boolean. Sum types add the options of each variant, product types multiply the options for each item in it. |