lua-users home
lua-l archive

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




On Mar 14, 2018, at 2:40 PM, pocomane <pocomane_7a@pocomane.com> wrote:


```
local t = {1}
t[1] = undef
print('1', t[1] == undef)
print('2', t[1] == nil)
```

Why are both true? I know why, I am just anticipating the discussion
that will substitute the # ones. Then someone will ask "But, can we
just make case-2 to be false?". Than someone else will replace, "No
because It will mean to make undef a value”

As Roberto notes, “undef” is NOT a value, you can’t use it in an equality check. It’s just a magic syntax that is allowed ONLY as the RHS of a table element assignment. (I think…)

—Tim