Jump to content

Trouble iterating table in Lua


thehankinator
 Share

Recommended Posts

I've got the below code:

local t = {}
local e = {}
local i = 100
e.val = i

table.insert(t, e)

for k,v in pairs(t) do
System:Print(tostring(v.val == i))
if v.type ~= i then
System:Print("false")
end
end

 

The output is:

true
false

 

I wouldn't have thought that I'd see the "false" print after a "true". Any idea what I am missing? It's got to be something simple...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...