Property discussion wrap-up

Rob T alanb at ucora.com
Tue Jan 29 22:38:29 PST 2013


On Wednesday, 30 January 2013 at 05:44:36 UTC, Zach the Mystic 
wrote:
>
> Why "alias this" in your version instead of opCall or opGet?

opCall requires parens, probably to disambiguate from alias this.

string A
{
   int i;
   int opCall() { return _i; }

}

A a,

int i = a; // error
int i = a(); // works

You can however do this

alias opCall this;

int i = a; // works
int i = a(); // works too

--rt


More information about the Digitalmars-d mailing list