lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


What about the types?
Does 235 == '235' ?

// David Morris-Oliveros
// Camera & Lua Coder
// david@teambondi.com



Damian Stewart wrote:
so i've got this function here:

function HandTrackOSCHandler:GetArmIndex( id )
    local idx = -1
    local k,v
    for k,v in pairs(self.arms) do
        local arm_id = v:GetId()
        print("'"..arm_id.."'","'"..id.."'","'"..k.."'")
        if id==arm_id then
            print("found")
            idx = k
            break
        end
    end
    print("returning "..idx)
    return idx
end

i'm passing in a number i get from a substring pattern match.

when i run the code, having set up everything else all ok, the print statements give me:

'235'   '235'   '1'
returning -1

in other words, even though 235 quite clearly == 235, the code inside the if statement never executes!

why does 235 not equal 235? why isn't 235==235 true?