When the faster Lua VM was released, they discouraged use of next because using pairs() would return a ‘faster’ next. I believe this was updated with time as now they are now using the same ‘next’.
I know loleris uses next in some weird way on ProfileService but I don’t know how to use it. He should have shown probably how to use next in different ways.
Next alone can be used to retrieve the first key-value pair in a table or if a key is specified then the next entry from that key. This is different from using it as a generator for a for loop. It’s very useful if you want to be able to get the next key-value pair without setting up a whole loop; additionally, as dictionaries do not have order, you do have to use it if you want to get the next entry.
ProfileService uses it recursively but if you want an easier and simpler example of it being used in a resource then check out Quenty’s Maid class. Next is used with a while loop to go through a task dictionary’s entries and clean them out while accounting for potentially new tasks that might get added during the cleanup up until next returns a nil key-value pair.
(Also sorry for the double reply notification you might’ve gotten, misread your post and deleted the other one I made.)
Please do surface-level researching on your own time! You can look through the Developer Hub or PiL if you see a function in use that you don’t know of.
pairs and ipairs received performance boosts in 2019 and was briefly covered in the RDC presentation Lua As Fast As Possible, so it’s not particularly surprising that they run faster and better. That and they’re canonical generators so regardless they should be used anyway unless you’re creating your own generator.