On 2011-04-20 01:35:46 +0300, %u said:

I have function which have more than one return, and the code compile and run
but it gives rong result -I guess-, so i use tuple but the compiler can't
return tuple.

how can I return values?
why I can't return tuple?

In D, tuple is not built in type, it is defined in stantard library. To use it, you must import module std.typecons

Example:
import std.typecons;
 
struct Foo {}
 
Tuple!(int, string, Foo) baz() {
    // some computation here
    return tuple(13, "inches", Foo());
}
 
void main() {
    auto bar = baz();
    assert(bar == tuple(13, "inches", Foo()));
}

Reply via email to