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

Making my own function like pairs() but getting an error..what to do?

Asked by 5 years ago
Edited 5 years ago

Hi, I am making my own function like pairs() but doesn't work with for loop..pls tell what to do?

function mypairs(t)

for key = 0,#t do

if key == 0 then

return(next t)

elseif key >= 1 then

return(next t,key)

elseif key == #t then

break

end

end

end

0
is this is a troll post BenSBk 781 — 5y
0
I got the answer NVM and nope not a troll post LitCoder 0 — 5y
0
@dandystan Do you not know how pairs works? It is obviously possible to implement your own iterator. Customality 21 — 5y
0
Internally, the pairs function is this: `function pairs(t) return next, t, nil end` User#24403 69 — 5y

Answer this question