Creating Anonymous structs
Alex
AJ at gmail.com
Sat May 18 20:53:50 UTC 2019
On Saturday, 18 May 2019 at 20:03:14 UTC, Adam D. Ruppe wrote:
> On Saturday, 18 May 2019 at 15:59:05 UTC, Alex wrote:
>> Structs combine data, I have a use case where I do not want to
>> litter the scope with variables and would like to put them in
>> a struct but the variable will only be used once.
>
> This is basically what Phobos's Tuple is.
>
> auto x = tuple(value_for_x, value_for_y);
>
> http://dpldocs.info/experimental-docs/std.typecons.tuple.html
I thought about using them but they are not the same. A tuple
cannot have functionality. It's not as general as a struct or
class and it doesn't look as nice if the struct is large... and
if we were to use a class we don't get to inherit.
More information about the Digitalmars-d-learn
mailing list