i had this:
Code: Select all
function lookfromtable(lookfor)
location = false
foreach(table, function (key, item)
if item = lookfor then location = key
endfunction
return(location)
Code: Select all
location = lookfromtable("string")
if location<>false
do stuff
else
return(false)
endif
If what I was looking for happened to be in key location 0, then when it returned location=0, it is same as "false", which means that even it actually did find what it was looking for, it didnt do what it was supposed to do, since location<>false, thought it was false situation.
All in all, this is a bit annoying situation when using foreach in this way, and it begs the question: Is there anyway to find out if what i return is a "false" or a "0", or are they simply one and same, in which case i have to make some extra lines to change it into returning string "notfound" instead.