[fpc-pascal] For-in-loop question about GetEnumerator
Mattias Gaertner
nc-gaertnma at netcologne.de
Sat May 17 14:48:26 CEST 2014
On Sat, 17 May 2014 13:18:01 +0200
Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
>
> Am 2014-05-17 10:39, schrieb Mattias Gaertner:
> > I added a note to the example, that the enumerator is automatically freed by the compiler after the loop.
>
>
> I just had a look at the UTF8 example on http://wiki.freepascal.org/for-in_loop where is says:
>
> ------------------------------------------------
> for i := 1 to Length(s) do
> DoSomething(ch[i]);
> ------------------------------------------------
>
> Isn't this wrong as i iterates over bytes but but not over (UTF8) characters?
Yes.
I replaced the example with a full implementation and some comments.
Mattias
More information about the fpc-pascal
mailing list