[fpc-devel] [] property overloads
Ryan Joseph
genericptr at gmail.com
Thu Jun 20 19:57:14 CEST 2019
I just had some plans for a cool JSON class thwarted because apparently [] properties don’t allow overloading of the parameters. Can we allow multiple default properties as long as their parameters are different? I know there’s not overloading of property names but at least the parameters could be overloadable so the correct property is chosen depending on what the args are.
type
TMyClass = class
function GetValueWithInt(index: integer): TValue;
function GetValueWithString(index: string): TValue;
property IndexI[index: integer]: TValue read GetValueWithInt; default;
property IndexS[index: string]: TValue read GetValueWithString; default;
end;
o := c[index]; // IndexI wins
o := c[‘key’]; // IndexS wins
Regards,
Ryan Joseph
More information about the fpc-devel
mailing list