cannot make opDollar work

spir denis.spir at gmail.com
Sun Dec 12 09:59:58 PST 2010


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 = 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 ☣

spir.wikidot.com



More information about the Digitalmars-d-learn mailing list