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: Isnt # string.len?

Previous Thread :: Next Thread 
metologyaddict is not online. metologyaddict
Joined: 09 Dec 2015
Total Posts: 378
25 Dec 2015 01:29 PM
[ Content Deleted ]
Report Abuse
wonderful72pike is not online. wonderful72pike
Joined: 13 Jul 2010
Total Posts: 7009
25 Dec 2015 01:35 PM
That's how it works in regular Lua, I'm not sure if it works in RBXLua but it should.
Report Abuse
getSolution3 is not online. getSolution3
Joined: 28 Aug 2010
Total Posts: 1132
25 Dec 2015 01:36 PM

table.getn which will return the length of the table, but that is deprecated now to replace the we use the #(Number operator) instead.


When people do this :

local Table = {"getSoltuion3",101,"gg"}

for i = 1, #Table do
print(Table[i])
wait()
end

They do 1, #Table do because 1 is the first position in the Data Structure where #Table is how many key there are in the Table.

print(Table[i]) is printing all the values in the table, because behind the scenes it is actually doing this:

for i = 1, 3 do
print(Table[i])
wait()
end

SInce they are only 3 Keys in our table, you can do for i = 1, 3 do also.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
25 Dec 2015 01:37 PM
Yes but it can also work with tables

local tab = {4,1,346,43}
print(#tab)

>4


#code Instance.new("BodyThrust",SenseiWarrior).position = CFrame.new(SenseiWarrior,YourGirlsDMs)
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
25 Dec 2015 01:38 PM
# is the length operator.

It can be used on string and tables by default but can also work with values with the len metamethod set(But tables in Lua 5.1.x are not effected by the len metamethod).

For getting the length of a string it is much faster than string.len.
Report Abuse
getSolution3 is not online. getSolution3
Joined: 28 Aug 2010
Total Posts: 1132
25 Dec 2015 01:39 PM
^ Why TF did I say #
Report Abuse
getSolution3 is not online. getSolution3
Joined: 28 Aug 2010
Total Posts: 1132
25 Dec 2015 01:39 PM
^ Number operator*
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