Ipairs or Pairs

So i wrote a data-store that uses Ipairs and someone commented on the YouTube video that i was incorrect.

Video:

I would like some opinions on this topic. As I have had errors with pairs more so than Ipairs in this case and really dont know what to believe.

ipairs is best but it needs to be an array without gaps.

pairs must be used for dictionaries or arrays with gaps.

The only “error” you could have with pairs is that the order is not guaranteed. With ipairs it goes through the array in order, hence needing to be an array with no gaps.

3 Likes

Ok, so this was the correct way of going about things, thank you!

1 Like

Here is a StackOverflow’s solution if you want it to be more clearly.
Link

1 Like

Yeah I saw that before asking on here. Thanks for extra clarity nice to get help.

1 Like