Perhaps add next() to the wiki?

So, it seems that actual Lua documentation is quite sparse yet again, I have a guy I’m teaching Lua, and the best way he could think of to see if a dictionary was empty was to do a pairs loop through it, I think it’d be at least a marginal benefit to add next() to the wiki, and a short description about how it can be used to check if a dictionary or sparse table is empty, because the return value will be nil if there is no value in that table:

local Dictionary = {[“Builderman”] = 1, [“John”] = “Blamed”}
print(next(Dictionary)) → “Builderman” 1

local EmptyDictionary = {}
print(next(EmptyDictionary)) → nil nil

And hey, maybe people here may not even know they can use next like this, it’s a decent optimization, and it makes code nice and clean

Uhhh…

1 Like

odd, searching next yielded nothing for me, when I was looking for the page to show to my student. Maybe the search thing is broken?

Weird. I always google the function/method/event etc I need. Usually works for me.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.