lua-users home
lua-l archive

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


True indeed. Maybe that's why I haven't encountered problems with it...

On 16/02/2011, at 9:23 PM, Roberto Ierusalimschy wrote:

Consider adding a new value next to "nil": "undefined".

local t = {}
print ( t["somestring"])  --- prints "undefined"
t["somestring"] = nil
print ( t["somestring"])  --- prints "nil"

Both undefined and nil evaluates to false when used in an if statement.

You may just rename "undefined"->"nil" and "nil"->"false":

t = {}
print(t["somesting"])    --> prints "nil"
t["somesting"] = false
print(t["somesting"])    --> prints "false"

Both nil and false evaluate to false when used in an if statement.

-- Roberto