[Gambas-user] Best way to enumerate multiple arrays or collections?

Benoît Minisini gambas at ...1...
Fri Aug 26 18:16:32 CEST 2016


Le 25/08/2016 à 20:00, Jussi Lahtinen a écrit :
> Sometimes I have code where I have multiple arrays or collections, which I
> would enumerate at once.
>
> Now I have to do it this way:
>
> For Each hObject In hCollection1
>   DoSomething ...
> Next
>
> For Each hObject In hCollection2
>   DoSomething ...
> Next
>
>
> And I would like to do it this way:
>
> For Each hObject In hCollection1, hCollection2
>   DoSomething ...
> Next
>
>
> Is this possible for future release of Gambas? Or is there some other
> preferred way?
> I guess with arrays you can use "insert" to combine the arrays in temporary
> array, but not with collections.
>
>
>
> Jussi

I don't think I will make the Gambas syntax more complex just to save 
three lines of codes...

Just write:

For Each hCollection In [hCollection1, hCollection2]
   For Each hObject In hCollection
     DoSomething...
   Next
Next

Regards,

-- 
Benoît Minisini




More information about the User mailing list