[fpc-devel] Property overloading vs. property array enumerators
Maciej Izak
hnb.code at gmail.com
Thu Jan 28 18:36:12 CET 2016
Another option :) from bugtracker by Kazantsev Alexey (
http://bugs.freepascal.org/view.php?id=28820#c89471 ) :
All you need is [s]love[/s] overloaded default properties. As in Delphi.
type
TObj = Class
Type
TValue = Type String;
TValues = Record
Function GetEnumerator : TEnumerator;
Property Items[AIndex : Integer] : TValue Read GetValueByIndex Write
SetValueByIndex; Default;
Property Items[Const AName : String] : TValue Read GetValueByName
Write SetValueByName; Default;
End;
Property Values : TValues Read GetValues;
End;
var v : TObj.TValue;
obj : TObj;
begin
obj.Values[1] := '1';
obj.Values['2'] := '2';
for v in Obj.Values do;
end.
--
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160128/cf5d42fc/attachment.html>
More information about the fpc-devel
mailing list