I’m making a saveable array to be a representation of a model and I need to convert between the 2 types of data. To do that, I’m making a function that does just that, but one of the things I need to do is get the number of objects in the array and the dev hub doesn’t say how (unless I overlooked it).
1 Like
You can simply say #Array
1 Like
#INSERT_ARRAY_HERE (30 characters long)
That’s for dictionaries and mixed tables. Explicit arrays can just be counted using #
operator.
I just gone into the developer hub, and it said this:
Iterating Over Arrays
Arrays can be iterated over (looped through) in two ways:
- Use the built-in
ipairs()
function in afor
loop. - Get the array’s length using the
#
operator and loop from 1 to that length value.
1 Like
That can be simply achieved by like other have said
print(#ArrayName)
1 Like
But OP is not asking for iteration over arrays but simply getting the length of an array.
Ok, ok, i just wanted to say that it was possible to do that.
Ok im making the script now it’s going well so far.
I’m very late but table.getn() returns the number of elements in an array
It’s also scheduled to be deprecated.