Returning multiple values from a function

Vino.B via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 4 00:27:12 PDT 2017


Hi,

  Can you help me in how to return multiple values from a 
function, the below code is throwing an error as below

Program:
import std.stdio: writeln;
import std.typecons: tuple, Tuple;

Tuple!(int, string[]) Params () {
int Test1;
string[] Path;
Test1 = 1;
Path = ["C:\\Temp\\TEAM1\\BACKUP", "C:\\Temp\\TEAM2\\ARCHIVE"];
return Test1;
return Path;
}

void main (){
int Test1;
string[] Path;
Params;
writeln(Test1);
writeln(Path);
}

Error:
TEx1.d(9): Error: cannot implicitly convert expression Test1 of 
type int to Tuple!(int, string[])
TEx1.d(10): Error: cannot implicitly convert expression Path of 
type string[] to Tuple!(int, string[])

From,
Vino.B


More information about the Digitalmars-d-learn mailing list