[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Propsoal: a lua dialect without nil
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 16 Feb 2011 11:23:50 -0200
> 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