Multiple return values...

Simen Kjærås simen.kjaras at gmail.com
Fri Mar 16 12:37:52 PDT 2012


On Fri, 16 Mar 2012 03:26:55 +0100, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> I think this is a reasonable request:
>
> (auto a, b) = fun();
>
> --->
>
> static assert(fun().length == 2);
> auto __t = fun();
> auto a = __t[0];
> auto b = __t[1];

That would be nice. As was mentioned in a later post, this works for  
static arrays, too.
Now, a pattern that our productive friend bearophile posted earlier was  
this:

int[] foo();

(auto a, b) = foo();

--->

auto __t = foo();
assert( __t.length > 0 );
auto a = __t[0];
auto b = __t[1..$];

Is this something we might also want?


More information about the Digitalmars-d mailing list