lua-users home
lua-l archive

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


>>>>> "Jonathan" == Jonathan Goble <jcgoble3@gmail.com> writes:

 Jonathan> And here's another argument for __ipairs: Imagine you want to
 Jonathan> write a array or list data structure that can include nils
 Jonathan> and is expected to iterate over the full length of the
 Jonathan> structure, including nils.

 Jonathan> With __ipairs, it's easy to get it to work with the built-in
 Jonathan> ipairs(), making it much easier for people to use your
 Jonathan> library.
 
Indeed someone posted a pretty much perfect example of that - a tuple
type using 5.4's multiple uservalues - more than two years ago when this
issue came up early in the 5.4 cycle.

-- 
Andrew.