Hi.
Um, can't find answer anywhere else..
What does number sign (#) operator do in Lua?
*SOLVED* A really-really small question.
*SOLVED* A really-really small question.
Last edited by ffive on Tue Nov 18, 2014 2:13 pm, edited 2 times in total.
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
Re: A really-really small question.
gives you the size of a table.
for ex, a table has 3 items, table[1], table[2], and table[3]
if you use #table, it will return 3, because thats how much items the table has
for ex, a table has 3 items, table[1], table[2], and table[3]
if you use #table, it will return 3, because thats how much items the table has
Re: A really-really small question.
Huge thanks!
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
Re: *SOLVED* A really-really small question.
no problem
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: *SOLVED* A really-really small question.
Note that it only works for the numeric part of a table (starting from 1, going until the next index is nil), so if you have gaps, then it won't report the "true" size of the table... and it doesn't count any other key either.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: *SOLVED* A really-really small question.
Let's not forget strings.
str = 'This is a string'
#str returns length of str - 16.
str = 'This is a string'
#str returns length of str - 16.
Re: *SOLVED* A really-really small question.
ah, coolRef wrote:Let's not forget strings.
str = 'This is a string'
#str returns length of str - 16.
for up to now i've been using string.len()
thanks for this info
Who is online
Users browsing this forum: No registered users and 1 guest