Can functions add properties?

Jun ltalbsjea at gmail.com
Fri Nov 23 06:08:04 PST 2012


I found some codes write

toStringz(myString)

as

mystring.toStringz

So I tested this code myself and it worked.

int pow2(int i)
{
     return i*i;
}
int myint = 5;
int otherint = myint.pow2;
assert(otherint == 25);

I've never seen any documentation about this behaviour. I think 
it's a good feature, but I'm a bit confused.


More information about the Digitalmars-d-learn mailing list