Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Advertisement
This function is implemented in FrameXML/UIParent.lua.

Returns whether a value is contained in the array portion of the table.

exists = tContains(table, value)

Arguments[]

table
Table - table to search.
value
Any - value to find in the array portion of the specified table

Returns[]

exists
Flag - 1 if the array portion of the table (sequential integer keys ascending from 1) contains the specified value, nil otherwise.

Implementation[]

function tContains(table, item)
       local index = 1;
       while table[index] do
               if ( item == table[index] ) then
                       return 1;
               end
               index = index + 1;
       end
       return nil;
end

Example[]

lotus = { "pink", "pretty" };
print(tContains( lotus, "yummy" )) -- false
Advertisement