How would one check if a word is NOT in an array... example:
fruits = { 'apple', 'banana' }
value = "carrot"
if not value == fruits then
print ( value .. " is not a fruit" )
end
or something like that? I would prefer pure Lua.
How would one check if a word is NOT in an array... example:
fruits = { 'apple', 'banana' }
value = "carrot"
if not value == fruits then
print ( value .. " is not a fruit" )
end
or something like that? I would prefer pure Lua.
The direct way:
local found = false
for _, v in ipairs(fruits) do
if v == value then
found = true
break
end
end
if not found then
print ( value .. " is not a fruit" )
end