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
 

Re: Length of an array

Previous Thread :: Next Thread 
chairman154 is not online. chairman154
Joined: 04 Jan 2013
Total Posts: 126
12 Jul 2014 09:29 PM
For example, how would I get the length of the following array?
local a = {["Cat"] = 1,["Pat"] = 3}
print(#a)
> 0
Report Abuse
chairman154 is not online. chairman154
Joined: 04 Jan 2013
Total Posts: 126
12 Jul 2014 09:30 PM
I don't want to do..

local count = 0
local a = {["Cat"] = 1,["Pat"] = 3}
for _, v in pairs(a) do
count = count+1
end
print(count)
>2

It's too long
Report Abuse
HyperProduct is not online. HyperProduct
Joined: 11 Nov 2012
Total Posts: 3362
12 Jul 2014 09:32 PM
To get the length of an array do:

print(#a)

or

print(#ArrayName)
Report Abuse
chairman154 is not online. chairman154
Joined: 04 Jan 2013
Total Posts: 126
12 Jul 2014 09:34 PM
bro



you did not read my post... when the index is not a number, it isn't counted with #
Report Abuse
chairman154 is not online. chairman154
Joined: 04 Jan 2013
Total Posts: 126
12 Jul 2014 09:42 PM
bro

are you guys serious
Report Abuse
HyperProduct is not online. HyperProduct
Joined: 11 Nov 2012
Total Posts: 3362
12 Jul 2014 09:42 PM
Oh, sorry. I read the post just not the code. My bad. :/
Report Abuse
chairman154 is not online. chairman154
Joined: 04 Jan 2013
Total Posts: 126
12 Jul 2014 10:13 PM
lovely...
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