www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - cannot make opDollar work

Hello,

Test case:

struct S {
    int[] ints;
    int opDollar () {return this.ints.length;}
    int opIndex (int i) {return this.ints[i];}
    int[] opSlice (int i, int j) {return this.ints[i..j];}
}

unittest {
    S s =3D S([3,2,1]);
    // _link_ error on each line:
    // Error: undefined identifier __dollar
    writeln(s[$-1]);
    writeln(s[0..$]);
    writeln(s[1..$-1]);
}

Thank you,
Denis
-- -- -- -- -- -- --
vit esse estrany =E2=98=A3

spir.wikidot.com
Dec 12 2010