[Doubt] Variadic arguments as reference (Possible?)

MattCoder mattcoder at gmail.com
Fri Jun 14 06:54:30 PDT 2013


On Friday, 14 June 2013 at 13:20:26 UTC, Regan Heath wrote:
> import std.stdio;
> import std.conv;
>
> void sum(double value, double*[] numbers ...){
> 	foreach(ref num; numbers)
> 		*num = *num + value;
> }
>
> void main(){
> 	double a = 1, b = 2, c = 3;
> 	sum(10, &a, &b, &c);
> 	
> 	writeln("a = "~to!string(a),
> 			"\nb = "~to!string(b),
> 			"\nc = "~to!string(c));
> }
>
> R

Hi Regan,

My fault, I thought that those variadics only works with "in" 
after I assume wrong from 
(http://ddili.org/ders/d.en/parameter_flexibility.html), but your 
code works well.

Thanks,

Matheus.


More information about the Digitalmars-d-learn mailing list