Hi, I’ve Created A Function That I Think Is Useful
**CODE**
function CompareTable(Value,Table)
if typeof(Table) ~= "table" then
error("table expected, got " .. typeof(Table))
end
for i,v in pairs(Table) do
if v == Value then
return true
end
end
return false
end
function CompareTabletoIndex(Value,Table)
if typeof(Table) ~= "table" then
error("table expected, got " .. typeof(Table))
end
for i,v in pairs(Table) do
if v == Value then
return i
end
end
return false
end
I think it would be good to give a type to the Table parameter, and enable strict typing, that way you don’t have to perform a check to make sure the value passed is a table type.