Little quiz

Jacob Carlborg doob at me.com
Fri Mar 25 03:52:32 PDT 2011


On 2011-03-25 01:50, bearophile wrote:
> A little quiz for people here: guess the output of this little D2 program (it compiles correctly and doesn't crash at run time, so it's a fair question):
>
>
> import std.typecons: tuple;
> import std.c.stdio: printf;
>
> auto foo() {
>      printf("foo\n");
>      return tuple(1, 2);
> }
>
> void main() {
>      foreach (x; foo().tupleof)
>          printf("%d\n", x);
> }
>
>
> Bye,
> bearophile

I would guess it prints the values of all the fields in the struct 
returned by "tuple".

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list