Talk:Table.size: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 9: Line 9:
Of course it's a bad idea to use this function for a table with only numerical indices.<br/>
Of course it's a bad idea to use this function for a table with only numerical indices.<br/>
[[User:NeonBlack|NeonBlack]] 16:19, 13 July 2009 (CEST)
[[User:NeonBlack|NeonBlack]] 16:19, 13 July 2009 (CEST)
----
Indded, I actually just attempted it with non-numerical indices and found it didn't work.  I stand corrected. :D
I shall leave my humiliation (lol) here so anyone else wondering what the point of this function would be can see that it is for non-numerical indices.
--[[User:Subenji99|Subenji99]] 20:43, 13 July 2009 (CEST)

Revision as of 18:43, 13 July 2009

What about using the builtin lua function:

table.getn(table)

--Subenji99 06:54, 13 July 2009 (CEST)


table.getn was replaced by the #-operator, which returns the number of table elements with a numerical (!) index.
table.size counts all elements regardless of which type their index is.
Of course it's a bad idea to use this function for a table with only numerical indices.
NeonBlack 16:19, 13 July 2009 (CEST)


Indded, I actually just attempted it with non-numerical indices and found it didn't work. I stand corrected. :D

I shall leave my humiliation (lol) here so anyone else wondering what the point of this function would be can see that it is for non-numerical indices. --Subenji99 20:43, 13 July 2009 (CEST)