generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Which takes less memory?

Previous Thread :: Next Thread 
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
02 Jan 2016 02:26 PM
So I want to know something. When you pass a literal table to a for loop like this:

for k, v in next, {somehugetable} do
...

Does it redeclare the table for every iteration? Is it different from doing it like this?

local a = {somehugetable}
for k, v in next, a do
...
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Jan 2016 02:28 PM
No, they're both the same but if you want to do something with the table you're going to have to use the second one. Also if the table is going to be iterated constantly (say you're doing #1 or #2 in a while loop or something) it might be a better idea to just reuse it.
Report Abuse
dennis96411 is not online. dennis96411
Joined: 06 Mar 2009
Total Posts: 1079
02 Jan 2016 02:29 PM
So basically it becomes cached in the iterator function?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Jan 2016 02:29 PM
Yeah. The table itself is fetched a single time and passed to the iterator function over and over.
Report Abuse
UnstableScript0 is not online. UnstableScript0
Joined: 21 Dec 2015
Total Posts: 1189
02 Jan 2016 02:29 PM
wot

When I looked up "Ninjas" in Thesaurus.com, it said "Ninja's can't be found" Well played Ninjas, well played.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image