Please help, I am unable to understand what inpairs {} and inpairs () and pls give an example
1 Like
There’s not much a difference. Here’s an example:
If I do:
for _, obj in pairs{game.Workspace:GetChildren()} do
print(obj)
end
What prints out is a table of all of the objects in game.Workspace
If I do:
for _, obj in pairs(game.Workspace:GetChildren()) do
print(obj)
end
What prints is a line of the object’s name, and all the objects will be printed out on their own line.
2 Likes
ipairs({1, 2, 3})
and ipairs{1, 2, 3}
are exactly the same.
https://www.lua.org/manual/5.1/manual.html#2.5.8
A call of the form
f{fields}
is syntactic sugar forf({fields})
Also works with strings:
A call of the form
f'string'
(orf"string"
orf[[string]]
) is syntactic sugar forf('string')
1 Like