Quantcast What's the point of ipairs!? - WoWInterface
Thread Tools Display Modes
12-09-12, 05:20 AM   #1
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
What's the point of ipairs!?

Hey all.

I've discovered that pairs() can be used for integer and string based tables.

When using pairs() with a integer based table, it also still re-evaluates the key numbers if a field is removed during the iteration.

So what's the point of ipairs()?
  Reply With Quote
12-09-12, 07:09 AM   #2
A Molten Giant
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 882
ipairs() requires the index to start at 1, and stops when there is a nil value, even if there is more entries in the table after said nil value. pairs() iterates through the entire table regardless of index or value.

  Reply With Quote
12-09-12, 07:11 AM   #3
Premium Member
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 686
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
12-09-12, 09:55 AM   #4
A Black Drake
Tuller's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 89
Generally, if I have an "array" and I care about ordering, I use ipairs. If I don't care, I use pairs.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » What's the point of ipairs!?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off