lua-users home
lua-l archive

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


You would have to invent a different nil for that reason, and check against it.

Somewhere

-- "function() end" would gurantee an unique value, differentiated from others, unless the VM merges it under one umbrella. Even them, maybe reusing coroutine might return you an unique value for the lifetime of the application (or something even simpler)

NULL = function() end
or
NULL = coroutine.create(function()end)

a.key = NULL

and then use NULL as your special null value.

On 7/23/2012 7:50 PM, meino.cramer@gmx.de wrote:
Hi,

Suppose one do

a = { key = nil }
print( a.key )

=> nil

print( a.carkey )

=> nil

It looks like setting a key in a hash with value nil is the
same as if the key does not exist at all.

How can I decide between both in a program?
Is there a 'exists' function as in Perl?

Best regards and thank you very much in advance for any help!
mcc