Which is one is better? pairs() or ipairs()?
And what is the difference between them?
Which is one is better? pairs() or ipairs()?
And what is the difference between them?
It depends on the usage
Simply:
pairs()
is used for Dictionaries
ipairs()
is used for Arrays
ipairs()
is better as it stops yielding if it reaches nil
in a table
Honestly, neither doesn’t have to be used on Roblox’s Luau (it’s not required anymore).
Luau will automatically determine whether or not a table will require ipairs()
for perfect numerical tables (all indices numerical, no skipping of index) or pairs()
(for dictionaries and everything else).
If were’ talking about vanilla Lua, ipairs
and pairs
still have to be used.
Pretty sure it just uses pairs, it doesn’t determine automatically.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.