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 » Scripting Helpers
Home Search
 

Ipairs pairs

Previous Thread :: Next Thread 
chester101 is not online. chester101
Joined: 02 Sep 2008
Total Posts: 149
30 Jan 2013 06:09 PM
So what is the difference between ipairs and pairs?
Report Abuse
YellowBrick1 is not online. YellowBrick1
Joined: 06 May 2009
Total Posts: 865
30 Jan 2013 06:11 PM
Ipairs only goes over keys that are natural numbers and stops when it reaches a key with a nil value. Pairs goes over every key value.
Report Abuse
chester101 is not online. chester101
Joined: 02 Sep 2008
Total Posts: 149
30 Jan 2013 06:11 PM
oh thank you so which would be better to use?
Report Abuse
YellowBrick1 is not online. YellowBrick1
Joined: 06 May 2009
Total Posts: 865
30 Jan 2013 06:12 PM
In most cases, pairs would be better, in my opinion.
Report Abuse
Inordinatus is not online. Inordinatus
Joined: 24 Dec 2012
Total Posts: 155
30 Jan 2013 06:13 PM
ipairs iterates until a nil is reached.
pairs iterates all the way through.

    Numbers = {1;2;3;4;5;nil;7;8;nil;10}

    for i,v in pairs(Numbers) do
      print(v)
    end

>1, 2, 3, 4, 5, 7, 8, 10

    for i,v in ipairs(Numbers) do
      print(v)
    end

>1,2,3,4,5


ιησя∂ιηαтυѕ
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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