lua-users home
lua-l archive

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


> I think that a big part of the problem is that people feel 'nil'
> should somehow be treated differently from other values when storing
> it in a table  used as an array. I don't see why.

oh, this is easy. Nil is nothing, no value, not even null, just plainly a name for the absence of a value. So if you assign nil to a variable or a table key, you are saying that there is no value stored there. And as nothing is very different from anything else, it should be treated differently. As an example, storing nil as a value for a key in a table, thus removing any value stored there and replacing it with nothing, will also remove the key, which seems perfectly reasonable to me.

Gunnar