of     1   

Zarkonan_Zenheart
#208281282Thursday, January 26, 2017 6:35 PM GMT

what's the difference? I remember in pairs is a banned practice but I don't remember why
Soybeen
#208281391Thursday, January 26, 2017 6:38 PM GMT

They're essentially no different, however, I recommend you use "for _,v in next,table do" pairs() calls upon next, from what I remember it's just an extra seemingly unnecessary step but if you want your table in parenthesis for organization's sake, then go for it.
chimmihc
#208281398Thursday, January 26, 2017 6:38 PM GMT

There is no functional or performance difference. You remembered wrong.
Soybeen
#208281418Thursday, January 26, 2017 6:39 PM GMT

Who said it was a banned practice? Was it Time? ;P
Soybeen
#208281474Thursday, January 26, 2017 6:41 PM GMT

Never said there was a functional difference but I explicitly remember being told that in pairs() just returns the next function -- from the lua site function pairs (t) return next, t, nil end so you might as well use next, and save yourself the keystrokes for the parenthesis()
chimmihc
#208281514Thursday, January 26, 2017 6:42 PM GMT

My post wasn't a reply to yours. Look at the times.
Soybeen
#208281599Thursday, January 26, 2017 6:45 PM GMT

Oh! Hah :)
Soybeen
#208281694Thursday, January 26, 2017 6:48 PM GMT

A question, though: how is there no performance difference? If it's comparable to this, then... function Bar() return "somedata" end function Foo() return Bar() end data Bar() would be (albeit unnoticeably) faster than Foo(), no?
Zarkonan_Zenheart
#208281796Thursday, January 26, 2017 6:51 PM GMT

I don't remember incorrectly ;^) https://forum.roblox.com/Forum/ShowPost.aspx?PostID=192642752 "The pairs function makes a new version of next every time you call it. It's bad. Using pairs should be an outlawed practice unless readability demands it." I don't really get what that means though.
Soybeen
#208281861Thursday, January 26, 2017 6:53 PM GMT

She's just trying to say the extra step is unnecessary "unless readability demands it" which I said almost verbatim. If you want parenthesis cuz they help you organize, do it up.
cntkillme
#208282140Thursday, January 26, 2017 7:01 PM GMT

She means what I told her on slack. Every time you call pairs, Lua retrns a new closure of next. It's not bad or anything, it's just how it works. Same when you get a CFrame/Vector3 method. print(cf.toWorldSpace, cf.toWorldSpace) Pairs only costs ONE extra function call BEFORE everything happens, meaning the size of your array doesn't affect the negligible speed difference because the next function is still being used for iterating.
cntkillme
#208282178Thursday, January 26, 2017 7:02 PM GMT

Actually not sure if I told her on slack or if it was someone else whatever.
Soybeen
#208282198Thursday, January 26, 2017 7:03 PM GMT

So why does pairs even exist?
cntkillme
#208282280Thursday, January 26, 2017 7:06 PM GMT

Consistency (because ipairs exists) and readability (some people prefer calling pairs because it might be "prettier" to them).
Zarkonan_Zenheart
#208282517Thursday, January 26, 2017 7:12 PM GMT

Thank you #### ##### #### That's been bothering me for close to half a year now.

    of     1