How to find the length of a table?

My table is similar to this:

Obbies = {{"Cheese", 5, 6, 7}, {"Apples", 4, 7, 2},{"Grapes", 1, 7, 3}}

All I would like to do is find the length (number of tables) of Obbies, and then find the length (number of items, including tables if there were any) of one of those tables.

I have tried both of these:

print(Obbies.len)
print(Obbies[2].len)

They both either return nil, or “table:” followed by a string of about 15 characters.

Am I using the wrong keyword, or is it something else.

7 Likes

print(#Obbies)

3

24 Likes

There is also table.getn(Obbies), however the # operator is really the best choice.

7 Likes

Thank you both, I was only confused because it wasn’t stated in the Tables articles I read.

2 Likes