lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, May 21, 2020 at 10:53 AM Andrea <andrea.l.vitali@gmail.com> wrote:
why ipairs does exist when one can do a for loop from 1 to #t?

Historical reasons. It almost got removed and got put back due to public outcry. The main reason is because it makes the iterator syntax more consistent.
 
why the _ipairs metamethod was deprecated?

Because there's no need for a metamethod for something as simple as ipairs() and if you want different iteration behavior you should just provide a different iterator.

/s/ Adam