With statement extension

Adrian Matoga via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 28 01:28:50 PDT 2016


On Wednesday, 27 April 2016 at 18:34:18 UTC, Artur Skawina wrote:
> [...]
>
>    void foo (Matrix matrix, SameType e1, SameType e2)
>    {
>        ref M()   { return matrix.rawArr; }
>        ref Ex1() { return e1.someProperties.someModulusX; }
>        ref Ey1() { return e1.someProperties.someModulusY; }
>        ref Ex2() { return e2.someProperties.someModulusX; }
>        ref Ey2() { return e2.someProperties.someModulusY; }
>        ref v()   { return e1.someProperties.aRatio; }
>
>        foreach (i; ...) foreach (j; ...) {
>            M[...] = Ex1 > Ex2 ?
>            1/v^^2 * sqrt(v * (Ex1 + Ex2)^^2 + v^^2 * (Ey1 - 
> Ey2)^^2) :
>            1/v^^2 * sqrt(v * (Ex1 + Ex2)^^2 + v^^2 * (Ey1 + 
> Ey2)^^2) ;
>        }
>    }
>
> artur

Unless any of the properties is an enum or, well, a @property, 
and I'd expect both in such case.



More information about the Digitalmars-d mailing list