lua-users home
lua-l archive

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


On 03/13/2018 07:43 PM, Roberto Ierusalimschy wrote:
>> btw, I notice that there is a new keyword, "undef", not mentions in manual,
>> is that just a undocumented feature or the doc just not the latest?
> 
> I am grad you asked :-)
...
> t[i]=undef is a special syntax form that means "remove the key 'i'
> from table 't'". You can only use 'undef' in three specific forms:
> 
>   t[i] = undef     -- remove a key from a table
>   t[i] == undef    -- test whether a table has a key
>   t[i] ~= undef    -- test whether a table has a key
> 
> Any other use of 'undef' gives a syntax error.

So you couldn't do:

function foo()
  return undef
end

t[i] = foo()
t[i] = bar or undef

Still, very interesting feature idea.

Scott