lua-users home
lua-l archive

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


> On Jan 9, 2015, at 12:45 PM, Enrique Arizón Benito <enrique.arizonbenito@gmail.com> wrote:
> 
> Hi,
> 
> as Rob Kendrick indicated, replacing nil and raising an exception is the only possibility. (and it's a good thing to do, since this avoid the program to continue with an un-initialized variable).
> 
> Regards,
> 
> Enrique
> 

But there is no such thing as an uninitialized variable in Lua. In Lua, all variables always contain a value at all times, and sometimes that value happens to be nil, be it a local variable, global, upvalue or function argument. In fact, one way to conceptualize a Lua table is that every table has ALL possible keys defined (an infinite number of keys), the vast majority of which just happen to contain nil.

—Tim