Returning multiple values from a function without Tuple
snarwin at gmail.com
Sun Sep 13 10:33:11 UTC 2020
On Sunday, 13 September 2020 at 10:26:21 UTC, tcak wrote:
> Let's say I have defined a function and its return type is set
> to "auto".
> auto test()
> return struct(
> name = "Adam",
> country: string = "Denmark",
> age: ubyte = 37
> Compiler would define an automatically generated struct into
> code that exactly fits to the returned struct. When I call the
> above function as below,
> auto info = test();
> Type of the variable "info" is going to be that automatically
> generated struct, and values of the returned struct are going
> to be copied into it.
Isn't this exactly what Tuple already does? The only difference
is that the struct is generated by a template in the standard
library, and not by the compiler.
More information about the Digitalmars-d