View Single Post
02-23-13, 07:26 AM   #1
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Checking a value against every value in a table

Back with another LUA question:

I am interested if LUA inherently supports checking a value against ANY value in a table. Let me explain.

Let us say we have a table with some values:

Lua Code:
  1. local myTable = {
  2.     "Value1",
  3.     "Value2",
  4.     "Value3"
  5. }

Is there any way I can check some variable against the whole table as in:

Lua Code:
  1. if some variable == ANY value in myTable then code here end

I am curious because using a
Lua Code:
  1. for k, v in pairs(myTable)
loop seems a bit bulky just to decide if the variable matches any value in said table.

Thank you for your time and assistance!

Last edited by Clamsoda : 02-23-13 at 07:33 AM.
  Reply With Quote