Skip to content

nill不是Lua的关键字 #2

@Eroica-cpp

Description

@Eroica-cpp

nil 才是关键字,比如:

local myHero = Heroes.GetLocal()
if myHero == nil then ... end -- correct
if not myHero then ... end -- correct
if myHero == nill then ... end -- wrong
`
有意思的是,对于未声明的变量:

wtf == 1 -- false
wtf == nil -- true
wtf == nill -- true
wtf == nillonglongstring -- true
wtf == anotherWtf -- true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions