On Fri, 14 Jun 2013 13:55:29 +0100, MattCoder <mattco...@gmail.com> wrote:
I want to know if there is a way to pass variadic arguments as reference? DMD says no!

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
--
Using Opera's revolutionary email client: http://www.opera.com/mail/

Reply via email to