February 06, 2021
Hi,

lets say i want to create a function that returns multiple values - e.g. Tuple!(string,string).

Why/when i should prefer Tuple as a return type over returning a struct (or even string[2] in this case)?

Thank you

February 06, 2021
On Saturday, 6 February 2021 at 18:02:46 UTC, Martin wrote:
> Why/when i should prefer Tuple as a return type over returning a struct (or even string[2] in this case)?

A Tuple is just a struct declared inlined. I personally use struct every single time - structs can be separately documented and be custom tailored to other situation, more compatible if you change your mind and add stuff later - but I guess if it is utterly trivial the inline definition of Tuple might be convenient.