Tuple or struct as return type?

Adam D. Ruppe destructionator at gmail.com
Sat Feb 6 18:09:58 UTC 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.


More information about the Digitalmars-d-learn mailing list