Jump to content

Recommended Posts

Posted

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...

Posted

Where is .type coming from? My guess is that's nil and so a nil would be not equal to 100 so it would print false. I think you mean:

 

if v.val ~= i then

  • Upvote 1

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.

×
×
  • Create New...