title: Why is my for loop reading only 3 values from my table and then producing error "attempt to index field '?' (a nil value)"... value does exist
body: <p>I have a table with numbers as keys, and a table (that contains two numbers) as their values. My goal is to create a loop that will reference several keys but I keep getting a 'nil' error on my 4th iteration of the for loop... even though the key/value does exist.</p>
  
  <p>Here is the table I am working with:</p>
  
  <pre><code>local TotalVolume = {[1.508] = {7788000, 3185000},
  [1.548] = {8591000, 3115000},
  [1.588] = {7660000, 2491000},
  [1.5395] = {5696000, 1137000},
  [1.5795] = {7633000, 2419000},
  [1.4755] = {5278000, 4159000},
  [1.5155] = {8502000, 1055000},
  [1.5555] = {7438000, 3932000},
  [1.4515] = {6426000, 4126000},
  [1.5955] = {5101000, 4167000},
  [1.4915] = {9132000, 1344000},
  [1.5315] = {5053000, 3143000},
  [1.5715] = {4940000, 3716000},
  [1.4675] = {9107000, 3516000},
  [1.5075] = {6984000, 2579000},
  [1.5475] = {9424000, 3743000},
  [1.5875] = {5519000, 4125000},
  [1.4835] = {6844000, 1276000},
  [1.5235] = {6150000, 4299000},
  [1.5635] = {8303000, 3790000},
  [1.4595] = {7359000, 1987000},
  [1.4995] = {8329000, 1945000},
  [1.451] = {7718000, 2628000},
  [1.491] = {8117000, 1612000},
  [1.531] = {4532000, 3449000},
  [1.571] = {9465000, 2490000},
  [1.467] = {7734000, 3388000},
  [1.507] = {7955000, 3075000},
  [1.547] = {6063000, 3737000},
  [1.587] = {6654000, 4455000},
  [1.483] = {7344000, 3287000},
  [1.523] = {9304000, 3510000},
  [1.563] = {8961000, 3284000},
  [1.459] = {8809000, 3790000},
  [1.499] = {6902000, 1627000},
  [1.539] = {8394000, 3122000},
  [1.579] = {5329000, 3191000},
  [1.475] = {5311000, 4319000},
  [1.515] = {9514000, 3113000},
  [1.555] = {9704000, 3914000},
  [1.595] = {6523000, 2764000},
  [1.5465] = {8945000, 1385000},
  [1.5865] = {9722000, 4054000},
  [1.4825] = {9091000, 1026000},
  [1.5225] = {9047000, 4353000},
  [1.5625] = {9203000, 1133000},
  [1.4585] = {4813000, 3088000},
  [1.4985] = {7489000, 1166000},
  [1.5385] = {4580000, 1355000},
  [1.5785] = {9568000, 3291000},
  [1.4745] = {8349000, 2717000},
  [1.5145] = {7668000, 4024000},
  [1.5545] = {6692000, 2458000},
  [1.4505] = {5563000, 3812000},
  [1.5945] = {8243000, 4180000},
  [1.4905] = {9137000, 3156000},
  [1.5305] = {7835000, 2323000},
  [1.5705] = {9463000, 1283000},
  [1.4665] = {6017000, 1882000},
  [1.5065] = {6759000, 1627000},
  [1.458] = {6979000, 2167000},
  [1.498] = {8637000, 3370000},
  [1.538] = {8469000, 3975000},
  [1.578] = {9501000, 2540000},
  [1.474] = {7205000, 1128000},
  [1.514] = {8925000, 1436000},
  [1.554] = {6350000, 4193000},
  [1.45] = {4506000, 2929000},
  [1.594] = {5601000, 1881000},
  [1.49] = {7422000, 1598000},
  [1.53] = {8285000, 2816000},
  [1.57] = {5823000, 2777000},
  [1.466] = {4548000, 4208000},
  [1.506] = {5750000, 3669000},
  [1.546] = {6212000, 1298000},
  [1.586] = {7757000, 1618000},
  [1.482] = {5176000, 2224000},
  [1.522] = {8559000, 2030000},
  [1.562] = {4952000, 3276000},
  [1.5135] = {7912000, 3388000},
  [1.5535] = {4759000, 1111000},
  [1.5935] = {8567000, 1401000},
  [1.4895] = {7649000, 1081000},
  [1.5295] = {7301000, 2276000},
  [1.5695] = {5702000, 1461000},
  [1.4655] = {8225000, 1102000},
  [1.5055] = {9421000, 1944000},
  [1.5455] = {7514000, 1712000},
  [1.5855] = {6681000, 3909000},
  [1.4815] = {8471000, 2611000},
  [1.5215] = {5339000, 2063000},
  [1.5615] = {4523000, 2404000},
  [1.4575] = {5414000, 3287000},
  [1.4975] = {5125000, 2536000},
  [1.5375] = {9254000, 3049000},
  [1.5775] = {8051000, 3264000},
  [1.4735] = {5429000, 3266000},
  [1.465] = {6567000, 1233000},
  [1.505] = {9624000, 1074000},
  [1.545] = {7654000, 1988000},
  [1.585] = {6927000, 3364000},
  [1.481] = {8253000, 3621000},
  [1.521] = {7061000, 2704000},
  [1.561] = {5723000, 2279000},
  [1.457] = {7810000, 3086000},
  [1.497] = {7543000, 951000},
  [1.537] = {5224000, 3950000},
  [1.577] = {5576000, 3707000},
  [1.473] = {8634000, 2144000},
  [1.513] = {8574000, 3103000},
  [1.553] = {9624000, 1188000},
  [1.593] = {8600000, 3551000},
  [1.489] = {4651000, 4481000},
  [1.529] = {7232000, 3756000},
  [1.4805] = {6037000, 2948000},
  [1.569] = {6521000, 3401000},
  [1.5205] = {6749000, 1975000},
  [1.5605] = {7672000, 1412000},
  [1.4565] = {7424000, 2956000},
  [1.4965] = {5658000, 1316000},
  [1.5365] = {4807000, 3201000},
  [1.5765] = {9370000, 4281000},
  [1.4725] = {7344000, 4464000},
  [1.5125] = {7220000, 1189000},
  [1.5525] = {5306000, 1350000},
  [1.5925] = {6444000, 3542000},
  [1.4885] = {7255000, 4105000},
  [1.5285] = {7209000, 2265000},
  [1.5685] = {6107000, 4221000},
  [1.4645] = {9121000, 985000},
  [1.5045] = {5019000, 2476000},
  [1.5445] = {4863000, 2440000},
  [1.5845] = {7824000, 3411000},
  [1.576] = {5344000, 3133000},
  [1.472] = {6838000, 3791000},
  [1.512] = {7715000, 2165000},
  [1.552] = {9404000, 1738000},
  [1.592] = {6634000, 2954000},
  [1.488] = {9117000, 2331000},
  [1.528] = {8146000, 1312000},
  [1.568] = {9900000, 3132000},
  [1.464] = {5964000, 1970000},
  [1.504] = {5036000, 3151000},
  [1.544] = {5251000, 3979000},
  [1.584] = {8044000, 2536000},
  [1.48] = {8526000, 2360000},
  [1.52] = {7498000, 2514000},
  [1.56] = {7809000, 3730000},
  [1.456] = {4549000, 2260000},
  [1.6] = {8487000, 1615000},
  [1.496] = {8935000, 3970000},
  [1.536] = {4653000, 2087000},
  [1.4875] = {5578000, 3641000},
  [1.5275] = {9560000, 2884000},
  [1.5675] = {6012000, 1422000},
  [1.4635] = {7863000, 2313000},
  [1.5035] = {7016000, 4493000},
  [1.5435] = {6713000, 1813000},
  [1.5835] = {5587000, 1461000},
  [1.4795] = {5355000, 2714000},
  [1.5195] = {8026000, 3852000},
  [1.5595] = {4539000, 4288000},
  [1.4555] = {5155000, 916000},
  [1.5995] = {4873000, 3333000},
  [1.4955] = {4508000, 1119000},
  [1.5355] = {9735000, 3103000},
  [1.5755] = {5541000, 1791000},
  [1.4715] = {5333000, 1710000},
  [1.5115] = {7826000, 3415000},
  [1.5515] = {5020000, 1831000},
  [1.5915] = {9472000, 2011000},
  [1.543] = {5296000, 3169000},
  [1.583] = {7749000, 1155000},
  [1.479] = {8995000, 2611000},
  [1.519] = {4936000, 1175000},
  [1.559] = {6895000, 4105000},
  [1.455] = {9937000, 2504000},
  [1.599] = {5284000, 2321000},
  [1.495] = {5890000, 1420000},
  [1.535] = {5224000, 3576000},
  [1.575] = {4712000, 1807000},
  [1.471] = {7648000, 2201000},
  [1.511] = {5836000, 1580000},
  [1.551] = {7386000, 2436000},
  [1.591] = {6665000, 2331000},
  [1.487] = {8566000, 2942000},
  [1.527] = {5749000, 1945000},
  [1.567] = {9714000, 1111000},
  [1.463] = {9983000, 4499000},
  [1.503] = {5481000, 4483000},
  [1.4545] = {5310000, 1497000},
  [1.4945] = {7801000, 3590000},
  [1.5345] = {5471000, 2247000},
  [1.5745] = {6211000, 4474000},
  [1.4705] = {8543000, 3092000},
  [1.5105] = {7553000, 4159000},
  [1.5505] = {4795000, 1193000},
  [1.5905] = {8507000, 4126000},
  [1.4865] = {9907000, 1972000},
  [1.5265] = {5076000, 2718000},
  [1.5665] = {4970000, 2887000},
  [1.4625] = {8788000, 3937000},
  [1.5025] = {5544000, 2109000},
  [1.5425] = {8890000, 4143000},
  [1.5825] = {4886000, 2302000},
  [1.4785] = {5552000, 1540000},
  [1.5185] = {5352000, 2077000},
  [1.5585] = {8262000, 4303000},
  [1.51] = {5513000, 3557000},
  [1.5985] = {6190000, 3410000},
  [1.55] = {7483000, 4446000},
  [1.59] = {9425000, 3457000},
  [1.486] = {7009000, 1879000},
  [1.526] = {8096000, 2059000},
  [1.566] = {8045000, 3444000},
  [1.462] = {9243000, 1654000},
  [1.502] = {8327000, 4230000},
  [1.542] = {7396000, 3100000},
  [1.582] = {8874000, 1607000},
  [1.478] = {9020000, 2995000},
  [1.518] = {9182000, 3580000},
  [1.558] = {7721000, 1818000},
  [1.454] = {5002000, 2212000},
  [1.598] = {4652000, 2178000},
  [1.494] = {9091000, 3449000},
  [1.534] = {9757000, 3171000},
  [1.574] = {5127000, 2357000},
  [1.47] = {7795000, 2287000},
  [1.4615] = {7041000, 1747000},
  [1.5015] = {7273000, 4367000},
  [1.5415] = {8913000, 3805000},
  [1.5815] = {6426000, 1031000},
  [1.4775] = {5342000, 4058000},
  [1.5175] = {5097000, 4029000},
  [1.5575] = {6693000, 1768000},
  [1.4535] = {6172000, 953000},
  [1.5975] = {4937000, 1172000},
  [1.4935] = {5271000, 3539000},
  [1.5335] = {7541000, 2185000},
  [1.5735] = {4520000, 3603000},
  [1.4695] = {8595000, 1289000},
  [1.5095] = {7612000, 2250000},
  [1.5495] = {5762000, 1798000},
  [1.5895] = {5931000, 2367000},
  [1.4855] = {9159000, 2041000},
  [1.5255] = {4897000, 4053000},
  [1.477] = {9817000, 3360000},
  [1.5655] = {4670000, 4028000},
  [1.517] = {6182000, 1526000},
  [1.557] = {7391000, 4338000},
  [1.453] = {8408000, 2749000},
  [1.597] = {8282000, 1225000},
  [1.493] = {6073000, 2111000},
  [1.533] = {6590000, 3728000},
  [1.573] = {5658000, 2544000},
  [1.469] = {7019000, 4317000},
  [1.509] = {7936000, 3495000},
  [1.549] = {5756000, 4009000},
  [1.589] = {4772000, 1928000},
  [1.485] = {7094000, 2250000},
  [1.525] = {7853000, 4342000},
  [1.565] = {8504000, 3700000},
  [1.461] = {7466000, 1412000},
  [1.501] = {7958000, 1476000},
  [1.541] = {6521000, 3280000},
  [1.581] = {5904000, 2329000},
  [1.5725] = {8768000, 4034000},
  [1.4685] = {8591000, 2586000},
  [1.5085] = {9202000, 3884000},
  [1.5485] = {6486000, 3984000},
  [1.5885] = {7950000, 3451000},
  [1.4845] = {7523000, 2145000},
  [1.5245] = {8818000, 2789000},
  [1.5645] = {5285000, 3382000},
  [1.4605] = {9758000, 4233000},
  [1.5005] = {7678000, 2817000},
  [1.5405] = {6375000, 2050000},
  [1.5805] = {7682000, 2831000},
  [1.4765] = {6846000, 1153000},
  [1.5165] = {6232000, 2949000},
  [1.5565] = {5925000, 915000},
  [1.4525] = {5457000, 3993000},
  [1.5965] = {8102000, 2479000},
  [1.4925] = {6227000, 4288000},
  [1.5325] = {8611000, 2689000},
  [1.484] = {9722000, 4217000},
  [1.524] = {5199000, 1136000},
  [1.564] = {7416000, 3368000},
  [1.46] = {9318000, 3516000},
  [1.5] = {6902000, 1736000},
  [1.54] = {5429000, 3147000},
  [1.58] = {9687000, 2846000},
  [1.476] = {8311000, 1991000},
  [1.516] = {8173000, 4416000},
  [1.556] = {8315000, 2332000},
  [1.452] = {9026000, 3588000},
  [1.596] = {5617000, 2765000},
  [1.492] = {5104000, 3575000},
  [1.532] = {9248000, 2669000},
  [1.572] = {5445000, 4408000},
  [1.468] = {7167000, 1639000}
  }
  </code></pre>
  
  <p>Here is a simplified for loop that produces the error I am getting:</p>
  
  <pre><code>function testForLoop()
  
  local price = 1.508
  
      for y = 1,10 do
          print("Checking bucket " ..tostring(price) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[price][1]))
          price = price + 0.0005
      end
  
  end
  </code></pre>
  
  <p>To show those values do exist in the table, here are simple print statements for the exact same keys that the for loop is referencing (and it works fine):</p>
  
  <pre><code>print("Checking bucket " ..tostring(1.508) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.508][1]))
  print("Checking bucket " ..tostring(1.5085) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.5085][1]))
  print("Checking bucket " ..tostring(1.509) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.509][1]))
  print("Checking bucket " ..tostring(1.5095) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.5095][1]))
  print("Checking bucket " ..tostring(1.51) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.51][1]))
  print("Checking bucket " ..tostring(1.5105) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.5105][1]))
  print("Checking bucket " ..tostring(1.511) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.511][1]))
  print("Checking bucket " ..tostring(1.5115) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.5115][1]))
  print("Checking bucket " ..tostring(1.512) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.512][1]))
  print("Checking bucket " ..tostring(1.5125) .. "   ---&gt;   Volume = " .. tostring(TotalVolume[1.5125][1]))
  </code></pre>
  
  <p>Does anyone have an idea what could be causing the for loop to fail when trying to reference this table?</p>