title: Looping over array values in Lua
body: <p>I have a variable as follows</p>
  
  <pre><code>local armies = {
      [1] = "ARMY_1",
      [2] = "ARMY_3",
      [3] = "ARMY_6",
      [4] = "ARMY_7",
  }
  </code></pre>
  
  <p>Now I want to do an action for each value. What is the best way to loop over the values? The typical thing I'm finding on the internet is this:</p>
  
  <pre><code>for i, armyName in pairs(armies) do
      doStuffWithArmyName(armyName)
  end
  </code></pre>
  
  <p>I don't like that as it results in an unused variable <code>i</code>. The following approach avoids that and is what I am currently using:</p>
  
  <pre><code>for i in pairs(armies) do
      doStuffWithArmyName(armies[i])
  end
  </code></pre>
  
  <p>However this is still not as readable and simple as I'd like, since this is iterating over the keys and then getting the value using the key (rather imperatively). Another boon I have with both approaches is that <code>pairs</code> is needed. The value being looped over here is one I have control over, and I'd prefer that it can be looped over as easily as possible.</p>
  
  <p>Is there a better way to do such a loop if I only care about the values? Is there a way to address the concerns I listed?</p>
  
  <p>I'm using Lua 5.0 (and am quite new to the language)</p>