This question is based off my observation with using the for loop, with the next function. I know the loop is written in this format:
for i,v in next, {} do
print(i,v)
end
But why aren't we calling the next function? Why are we using a comma, followed by what should be it's first argument? We do that with pairs and ipairs:
for i,v in pairs({}) do -- calling pairs()
print(i,v)
end
-- and...
for i,v in ipairs({}) do -- again, calling ipairs()
print(i,v)
end
-- but then...?
for i,v in next, {} do -- not calling next?
print(i,v)
end
So why isn't it written as:
for i,v in next({}) do -- you'd think this would be correct, but it's not.
print(i,v)
end
If anyone can help me with this, I'd very much appreciate it. Thanks.
