Can you fix this code to avoid using pointers?

XavierAP via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 11 04:35:42 PST 2017


I do not really think it's a bad solution, to check several 
scalar arguments that must obey the same condition; just 
wondering if you have better ideas. Try to avoid modifying the 
function's signature and defining custom types, unless you have a 
really terrific idea.

void calc(double in1, double in2, double in3, double in4)
in {
    foreach(const p; [&in1, &in2, &in3, &in4])
       enforce(*p > 0);
}
body { /* ... */ }



More information about the Digitalmars-d-learn mailing list