title: Determine if variable is one of several values in Lua
body: <p>I have a value <code>armyName</code> and need a function that checks if it is one of 8 values. As I'm quite new to Lua, I'm looking for what the best way to do this kind of check is.</p>
  
  <p>This works:</p>
  
  <pre><code>local function isPlayerArmyName(armyName)
      return armyName == "ARMY_1"
          or armyName == "ARMY_2"
          or armyName == "ARMY_3"
          or armyName == "ARMY_4"
          or armyName == "ARMY_5"
          or armyName == "ARMY_6"
          or armyName == "ARMY_7"
          or armyName == "ARMY_8"
  end
  </code></pre>
  
  <p>This also works:</p>
  
  <pre><code>local function isPlayerArmyName(armyName)
      local names = {
          ["ARMY_1"] = true,  ["ARMY_2"] = true, ["ARMY_3"] = true, ["ARMY_4"] = true,
          ["ARMY_5"] = true,  ["ARMY_6"] = true, ["ARMY_7"] = true, ["ARMY_8"] = true,
      }
  
      return names[armyName] or false
  end
  </code></pre>
  
  <p>They are both rather silly compared to this PHP code:</p>
  
  <pre><code>return in_array( $armyName, [ "ARMY_1", "ARMY_2", "ARMY_3", ..., "ARMY_8" ] )
  </code></pre>
  
  <p>Is there a better way to make such a check than the provided Lua code snippets? And if not, what would the typical Lua programmer prefer to come across; the first or second one?</p>
  
  <p>I'm using Lua 5.0.</p>