[fpc-pascal] How to find the return type of a for..in ?
Michael Van Canneyt
michael at freepascal.org
Thu Jun 16 17:49:53 CEST 2016
On Thu, 16 Jun 2016, Graeme Geldenhuys wrote:
> 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.
The return type of the GetEnumerator function tells you what the class is.
It is a good idea for a Lazarus IDE extension.
More information about the fpc-pascal