Can you fix this code to avoid using pointers?
Satoshi via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Mar 11 05:44:30 PST 2017
On Saturday, 11 March 2017 at 12:35:42 UTC, XavierAP wrote:
> 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 { /* ... */ }
void calc(in double[] array...) {
foreach (x; array) { }
}
More information about the Digitalmars-d-learn
mailing list