Returning multiple arrays from function - struct or byref the only option?

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 15 09:55:27 PDT 2014


Here is byref:


import std.typecons;
import std.stdio;

void myfunction(double x, ref double[] a, ref double[] b)
{
	a~=x+1.0;
	a~=x+9.0;
	b~=x+2.0;
	b~=x+11.0;
	return;
}

void main()
{
	double[] a;
	double[] b;
	myfunction(99.0,a,b);
	writefln("%s %s",a,b);
}


More information about the Digitalmars-d-learn mailing list