[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pairs and ipairs
- From: Petite Abeille <petite.abeille@...>
- Date: Mon, 23 Oct 2023 19:03:30 +0200
> On Oct 23, 2023, at 10:00, Francisco Olarte <folarte@peoplecall.com> wrote:
>
> Given the language gives you mechanism to build loops, generators (
> this coroutine looks like a generator in disguise ) are a bit overkill
> for just an iterator:
Yes! That said, considering that both you and Lars have written essentially the exact same code, coroutines bring a bit of diversity.
> local aNext = 1
> while aTable[aNext] ~= nil do
> aNext = aNext+1
> end
^ This is the crux of the irritant though — two passes.
As someone mentioned earlier on, perhaps best not to put oneself into this situation in the first place — use two tables.