adding properties/methods to AA's?

Oskar Linde oskar.lindeREM at
Mon Jul 23 03:56:53 PDT 2007

Alex skrev:
> Ok, so I've got a property (I guess that's the proper term to use?) that I'd like to be able to use with any AA declared as Variant[char[]].  For example, I'd like to be able to do the following.
> Variant[char[]] map;
> ubyte []stream;
> stream = map.serialize;
> map.deserialize( stream );
> int [int[]] map2;
> stream = map.serialize; //invalid, int [int[]] does not have serialize property.
> Is this even possible?  I'm sure someone will tell me to just write a function such as ubyte []serialize( Variant[char[]]input ), and I'm aware this is an option.  I just think the above looks a bit more slick.

just write the function as ubyte[] serialize(Variant[char[]] input) and 
call it as:

map.serialize(); // Note, the trailing pair of empty parentheses


More information about the Digitalmars-d-learn mailing list