Help - Trying to find if a given list is multidimensional

I need a way of finding if a given table is two dimensional or just one dimensional. Is there a way to do this?

I’ve tried using the following code but it always ends in an error if the table is one dimensional:  

if table[1][1] ~= nil then

 print(“two dimensional”)

end

if #table[1] > 0 then

 print(“two dimensional”)

end

Any ideas as to how to solve this?

You can check the ‘type’ of the object. maybe like :

if table[1] ~= nil and type(table[1]) == "table" then -- Yes, there is a table in 'table[1]' end

See https://docs.coronalabs.com/api/library/global/type.html

Thanks!

You can check the ‘type’ of the object. maybe like :

if table[1] ~= nil and type(table[1]) == "table" then -- Yes, there is a table in 'table[1]' end

See https://docs.coronalabs.com/api/library/global/type.html

Thanks!