Problem with delegates

Zarathustra adam.chrapkowski at gmail.com
Sun Sep 7 06:48:35 PDT 2008


I know it works with additional function like 'Comparator'.
Probably when I try use anonymous delegate it have not acces to this, because body of anonymous delegate must be nested inside for example constructor.

private class
Drawable{
  abstract real Comparator();
  [...]
}
public class
Point{
  [...]
  Comparator(){ return this.z; }
  [...]
}

Maybe I will find out another way to do this.


Frank Benoit Wrote:

> I haven't tried this, but i think it can work like this:
> // in Point
>    // ctors
>    this(uint o_x, uint o_y, uint o_z){
>      super( &comparator );
>      this.x = o_x;
>      this.y = o_y;
>      this.z = o_z;
>    }
>    real comparator(){ return cast(real)this.z; }
> 



More information about the Digitalmars-d-learn mailing list