title: lua Hashtables, table index is nil?
body: <p>What I'm currently trying to do is make a table of email addresses (as keys) that hold person_records (as values). Where the person_record holds 6 or so things in it. The problem I'm getting is that when I  try to assign the email address as a key to a table it complains and says table index is nil... This is what I have so far:</p>
  
  <pre><code>random_record = split(line, ",")
  person_record = {first_name = random_record[1], last_name = random_record[2], email_address = random_record[3], street_address = random_record[4], city = random_record[5], state = random_record[6]}
  email_table[person_record.email_address] = person_record
  </code></pre>
  
  <p>I wrote my own split function that basically takes a line of input and pulls out the 6 comma seperated values and stores them in a table (random_record)</p>
  
  <p>I get an error when I try to say email_table[person_record.email_address] = person_record. 
  But when I print out person_record.email_address it's NOT nil, it prints out the string I stored in it.. I'm so confused.</p>
  
  <pre><code>function split(str, pat)
     local t = {}  -- NOTE: use {n = 0} in Lua-5.0
     local fpat = "(.-)" .. pat
     local last_end = 1
     local s, e, cap = str:find(fpat, 1)
     while s do
        if s ~= 1 or cap ~= "" then
       table.insert(t,cap)
        end
        last_end = e+1
        s, e, cap = str:find(fpat, last_end)
     end
     if last_end &lt;= #str then
        cap = str:sub(last_end)
        table.insert(t, cap)
     end
     return t
  end
  </code></pre>