lua-users home
lua-l archive

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


"xenarcher " wrote:
> 
> Is it possible to distinguish between an undefined global variable
> and one that is defined but has the value 'nil'? Or does assigning
> the value 'nil' to a global variable essentially undefine that global?

Yes, a variable that is set to nil is essentially undefined.
Setting a defined variable to nil will effectively erase it's value, 
which will garbage collected at the next cycle. 

In Lua 5, you can usually solve this problem by setting the
variable to false. In boolean expressions, false and nil are 
equivalent, but false values are stored in variables, and are 
thus distinguishable from nil values.

-- 
"No one knows true heroes, for they speak not of their greatness." -- 
Daniel Remar.
Björn De Meyer 
bjorn.demeyer@pandora.be