[fpc-devel] Iterator for array properties
Ondrej Pokorny
lazarus at kluug.net
Sat Oct 10 12:36:26 CEST 2015
On 10.10.2015 12:30, Michael Van Canneyt wrote:
> After a
>
> sed s/iterator/enumerator/g
>
> I'm all for it.
>
> I've been looking how to implement names/objects/values enumerators in
> TStrings. This would be the almost perfect solution.
>
> But your example is not well-chosen, since the enumerator for
> TComponent already exists:
>
> Procedure TForm1.Button1Click(Sender: TObject);
> var
> Comp: TComponent;
> begin
> for Comp in Self do
> //...
> end;
>
> Just as an aside...
Yes, of course. I ment enumerator :)
TTest = class
// ...
property Objects[Index: Integer]: TObject read GetObject
*enumerator GetObjectEnumerator*;
property ObjectCount: Integer read GetObjectCount;
end;
+ Yes, the "in Self" is supported. But this is not the problem here. The
example still doesn't compile. A class can have more array properties.
And even the default class enumerators can be redeclared and so hide
enumerators from ancestor classes.
Maybe a better example:
*Procedure TForm1.Button1Click(Sender: TObject); **
** var **
** Cont: TControl; **
** begin **
** for Cont in Controls do **
** //... **
** end; **
***
Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20151010/4ee35136/attachment.html>
More information about the fpc-devel
mailing list