void calc(double in1, double in2, double in3, double in4) in { foreach(const p; [&in1, &in2, &in3, &in4]) enforce(*p > 0); } body { /* ... */ }
Can you fix this code to avoid using pointers?
XavierAP via Digitalmars-d-learn Sat, 11 Mar 2017 04:41:51 -0800
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.
- Can you fix this code to avoid using... XavierAP via Digitalmars-d-learn
- Re: Can you fix this code to av... XavierAP via Digitalmars-d-learn
- Re: Can you fix this code to av... XavierAP via Digitalmars-d-learn
- Re: Can you fix this code t... H. S. Teoh via Digitalmars-d-learn
- Re: Can you fix this code t... XavierAP via Digitalmars-d-learn
- Re: Can you fix this co... H. S. Teoh via Digitalmars-d-learn
- Re: Can you fix this co... XavierAP via Digitalmars-d-learn
- Re: Can you fix this code to av... Satoshi via Digitalmars-d-learn
- Re: Can you fix this code t... XavierAP via Digitalmars-d-learn
- Re: Can you fix this co... Adam D. Ruppe via Digitalmars-d-learn