[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looping through an array with FOR EACH
[Thread Prev] | [Thread Next]
- Subject: Re: Looping through an array with FOR EACH
- From: Brian G <brian@xxxxxxxxxxxxxxxx>
- Date: Thu, 15 Jan 2026 09:55:09 -0800
- To: user@xxxxxxxxxxxxxxxxxxxxxx
I think here we have have Ben step in, because what you are all stating is that 'for each' is a totally unreliable way of for instance listing a newly sorted array of strings... even the hint of a 'maybe not work' in a production environment is not acceptable on any level. I just don't believe for simple arrays that Ben would allow such a bug/instability to persist as part of such an amazing work!
If this is on any level true, perhaps this construct should be removed from the language it is therefore a useless construct.
No body should be afraid to use a tool as intended. Brian On 1/15/26 04:59, Gianluigi wrote:
Il 15/01/26 12:44, BB ha scritto:On 15/1/26 8:46 pm, Gianluigi wrote:Hi everyone,I seem to remember reading somewhere (perhaps in an email from Benoit?) that if you loop through an array with For Each in Gambas, you can't be sure of the correct sequence.Did I dream it, or is it true?I am going to interpret your "correct sequence" as "expected sequence". It is true. However rare to encounter.There is chance that after manipulating an array (in many ways) that the order in which For Each iterates is not the same as the last "order" as determined by the operations on the array.However, it is more a "beware of" rather than a rule.I believe that he was just making people aware of this, rather than trying to scare them.bAdmin and Bruce, thank you for your replies. My question stems from this post on the Gambas One forum: https://gambas.one/forum/index.php?page=topicview&type=findpost&id=13792The question was about how to construct and read a jagged array, and the answer above favored For Each over a simple loop with a counter. Since I know this is true for certain languages, I wanted to know if it was also true for Gambas.If I understand Bruce's answer correctly, using counters is preferable with Gambas.Regards Gianluigi
-- ~~~~ Brian
Attachment:
OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |
| Re: Looping through an array with FOR EACH | BB <adamnt42@xxxxxxxxx> |
| Re: Looping through an array with FOR EACH | Gianluigi <gradobag@xxxxxxxxxxx> |