[fpc-pascal] How to find the return type of a for..in ?

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Thu Jun 16 16:38:31 CEST 2016


On 2016-06-16 15:29, Mattias Gaertner wrote:
> Have you seen this page:

Yes, that's what I looked at to see how to use for..in but nowhere does
it mention or give a JSON example. Granted, I haven't read every single
word on that page, but a lot seem to cover how to implement an iterator
for your own containers so for..in loops can work with it. This was not
what I was looking for.

The fpjson unit already supports the for..in loop, I just didn't know
[immediately obvious] what data type the loop variable must be - hence
my question.

So it seems the only way to use for..in on moderate to complex objects
[that you haven't looped before], is to delve into the source code and
see how the enumerator class was implemented, and there you will find
the loop variable type to use.

Regards,
  Graeme



More information about the fpc-pascal mailing list