by duckfan77 · 1y ago · 0 comments
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.
No comments yet.