[Doubt] Variadic arguments as reference (Possible?)

MattCoder mattcoder at gmail.com
Fri Jun 14 05:55:29 PDT 2013


Hi,

I want to know if there is a way to pass variadic arguments as 
reference? DMD says no!

I wrote the snippet code below, but what I want to do in fact is 
assign the sum back to respective variables to use somewhere else.

http://dpaste.dzfl.pl/515edfb8

or

import std.stdio;
import std.conv;

void sum(double value, in double[] numbers ...){
	foreach(num; numbers)
		writeln(num+value);
}

void main(){
	auto a = 1, b = 2, c = 3;
	sum(10, a, b, c);
	
	writeln("a = "~to!string(a),
			"\nb = "~to!string(b),
			"\nc = "~to!string(c));
}

Thanks,

Matheus.


More information about the Digitalmars-d-learn mailing list