Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Tuple as function return value

Moderators: kris

Posted: 04/28/07 07:19:25

There is a sample in the description of tango.core.Tuple ( where tuple T2 is being used as function return value. But dmd.1.013 and dmd.1.014 detects an error here:

import tango.core.Tuple;

alias Tuple!(int, real) T1;
alias Tuple!(int, long) T2;

T2 func( T1 val )  // line 6
    T2 ret;
    ret[0] = val[0];
    ret[1] = val[0] * cast(long) val[1];
    return ret;

	auto r = func( 1, 1.3 );
dmd t1.d
t1.d(6): Error: functions cannot return a tuple

Regards, Yauheni Akhotnikau

Author Message

Posted: 04/28/07 07:47:36

Well that stinks. It worked back when Tuple was hand coded. I'll see if I can sort it out.