2 ms·
The difference, in terms of type theory, is that a tuple is a product type [1] but a type representing multiple possible return values (to represent different o
by harveywi 10y ago
The difference, in terms of type theory, is that a tuple is a product type [1] but a type representing multiple possible return values (to represent different outcomes) would be encoded using a sum type [2].
[1] https://en.wikipedia.org/wiki/Product_type https://en.wikipedia.org/wiki/Product_type
[2] https://en.wikipedia.org/wiki/Tagged_union https://en.wikipedia.org/wiki/Tagged_union
- eru 10y agoI don't think eg Go uses a sum type: https://gobyexample.com/multiple-return-values https://gobyexample.com/multiple-return-values Typically they use product types to simulate sum types.