Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is the purpose of this in for loops?

Asked by
novipak 70
9 years ago

I've seen this being used many times, but never really understood it.

Why is it that some people write their for loops like this:

for _,v in pairs(table) do
    --code here
end

Instead of this?

for i,v in pairs(table) do
    --code here
end

If you didn't see the difference, it's that instead of an "i" (or some other argument) being there, they put a "_". Is this just a name for the argument? Just a style some people do? Or does it *actually* do something?

1 answer

Log in to vote
1
Answered by 9 years ago

This already has some very good answers.

For a quick answer, they are the same. Simply variable names.

Read here and here for more information.

0
Alright, thank you for the clarification. novipak 70 — 9y
Ad

Answer this question