WoW:API tContains: Difference between revisions

no edit summary
m (Move page script moved page API tContains to WoW:API tContains without leaving a redirect)
No edit summary
 
Line 6: Line 6:




<big>'''Implementation'''</big>
; Implementation
function tContains(table, item)
<lua>
        local index = 1;
function tContains(table, item)
    local index = 1
         while table[index] do
         while table[index] do
                if ( item == table[index] ) then
            if item == table[index] then
                        return 1;
                return 1
                end
            end
                index = index + 1;
            index = index + 1
         end
         end
        return nil;
    return nil
end
end
</lua>


 
== Examples ==
== Example ==


  banana = { "yellow", "curved", "yummy" };
  banana = { "yellow", "curved", "yummy" };
Line 26: Line 27:
  eatme = tContains( lotus, "yummy" );
  eatme = tContains( lotus, "yummy" );


<big>'''Result'''</big>
;Result
  eatme = false
  eatme = false