overloading InExpression
Kozzi11 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 2 08:36:22 PDT 2014
On Wednesday, 2 July 2014 at 14:35:55 UTC, 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 and lack of documentation?
Maybe something from old days? But in current <a
href="http://dlang.org/operatoroverloading.html#Binary"
target="_blank">doc</a> there is a opBinary:
struct S
{
int opBinaryRight(string op : "in")(int key)
{
return key*2;
}
}
void main()
{
assert((42 in S.init) == 84);
}
More information about the Digitalmars-d-learn
mailing list