Comparison operator overloading

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 6 16:43:50 PST 2015


On 12/06/2015 06:41 AM, Márcio Martins wrote:

 > auto m = (a > b) * a + 15;
 > auto c = a.choose(a > b)^^2;

What do those operations do? Are you thinking of a special meaning for 
'>', perhaps common in numerical computations, which I'm not familiar with?

If I understand correctly, 'a > b' in choose(a > b) is the condition to 
pick elements from a. If so, it is better to pass a lambda in such cases:

   a.choose!((i, j) => i > j);

However, as I understand it, the whole expression is supposed to 
generate an array-like result. Is that right? :)

Ali



More information about the Digitalmars-d-learn mailing list