How can I write a function that determines whether it\'s table argument is a true array?
isArray({1, 2, 4, 8, 16}) -> true isArray({1, \"two\", 3, 4, 5}) ->
By "true array", I suppose you mean a table whose keys are only numbers. To do this, check the type of every key of your table. Try this :
function isArray(array) for k, _ in pairs(array) do if type(k) ~= "number" then return false end end return true --Found nothing but numbers ! end