Thread: ipairs bugged?
View Single Post
07/22/14, 08:23 PM   #6
Deome
 
Deome's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 29
Thumbs up

Originally Posted by merlight View Post
With the minor difference that ipairs doesn't even need to get #table. The generator it returns simply stops at the first nil element.
Yep. My addon relies HEAVILY on tables, and tables within tables ad nauseum, and I think there's only a single ipairs() call in 800 or so lines of code. Could be wrong, maybe two. If your table contains, or may contain, or may contain sometime in the future, anything other than a pure sequential index that starts with 1, just use pairs() to cycle through the whole thing. Besides, you can do so much more with pairs() than ipairs().

Also, my new favorite ZO function is NonContiguousCount(table). I haven't seen it mentioned much, but it's basically #table for non-sequential or alphabetical tables, which is a gods-send for me.
  Reply With Quote