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

Can anyone explain me how the functions Next and In Pairs Mean?

Asked by
CjayPlyz 643 Moderation Voter
5 years ago

Can anyone explain me how the functions Next and In Pairs Mean? The wiki is just too complicated for me.

1 answer

Log in to vote
1
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
5 years ago
Edited 5 years ago

pairs(table) returns next,table,nil.

in a for loop, you can use it to loop over each key,value in the given table.

Eg.

local Example = {
    "Hello";
    "World";
    "Bye!";
}

for _,Value in pairs(Example) do
    print(Value)
end

--[[
    this would print
    Hello
    World
    Bye!
]]
Ad

Answer this question