overloading InExpression
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 2 08:27:13 PDT 2014
On 07/02/2014 07:35 AM, Vlad Levenfeld wrote:
> On Wednesday, 2 July 2014 at 14:14:57 UTC, Dicebot wrote:
>> struct S
>> {
>> int opIn_r(int key)
>> {
>> return key*2;
>> }
>> }
>>
>> void main()
>> {
>> assert((42 in S.init) == 84);
>> }
>
> Thanks! I wonder, why the _r
I think it is the old syntax, meaning "this is the overload for when an
S object is on the right-hand side".
> and lack of documentation?
It appears in the binary operator table:
http://dlang.org/operatoroverloading.html#Binary
Also see the section 'Inclusion query by opBinaryRight!"in"' here:
http://ddili.org/ders/d.en/operator_overloading.html
Ali
More information about the Digitalmars-d-learn
mailing list