sjr04
(uep)
January 1, 2020, 9:25am
#1
In vanilla Lua, pairs
internally is really just
function pairs(t)
return next, t, nil
end
So it works the same as next, only more idiomatic. But in roblox, this is not the case.
print(pairs({ }) == next) -- prints true in vanilla lua, false in roblox
When i tried this:
print(pairs({ }) == pairs({ }) -- prints false in roblox, true in vanilla lua
I got false. So it looks like roblox made pairs return a new closure instead. Why is this?
1 Like
JinxFury18
(JinxFury18)
January 1, 2020, 9:54am
#2
I’m not that sure, but I think it’s because of the version of Lua Roblox uses. Roblox uses Lua 5.1, I think? Maybe it’s different from the version you are using.
I’m not entirely sure if that is the problem, but do try it out and let me know .
Autterfly
(Autterfly)
January 1, 2020, 6:14pm
#3
This is part of a recent optimization by Luau as far as I’m aware. Don’t know the specifics but loops with common iterators run hella faster.
1 Like