opDollar fixed??
    Era Scarecrow 
    rtcvb32 at yahoo.com
       
    Sat Dec 29 14:13:57 PST 2012
    
    
  
  Wasn't opDollar was fixed? Slices don't seem to be working... In 
one of my tests (can't duplicate here for some reason) using 
__dollar when it would see __dollar it complained about needing 
'this' access.
struct S {
   int[] x;
   this(int[] x) {this.x = x;}
   int opDollar() {return x.length;}
   int __dollar() {return x.length;} //doesn't see this either
   int[] opSlice(int s, int e) {return x[s .. e];}
   int opIndex(int i) {return x[i];}
}
unittest {
   S s1 = [1,2,3];
   int last = s1[$ - 1];  //works
   int[] x = s1[0 .. $];  //needs __dollar??
   writeln(last); //never gets here, but should be 3
   writeln(x);    //never gets here, but should be [1,2,3]
}
    
    
More information about the Digitalmars-d-learn
mailing list