lua-users home
lua-l archive

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


On Mon, Aug 16, 2010 at 4:36 PM, Peyman <peiman_3009@yahoo.com> wrote:
Hi All,
From Lua manual :
"in particular, the number 0 and the empty string are also true"
so my question is there anyway to create lua that 0 an empty string become true ? is there any work or patch for lua source ? in Lua 5.2 this is possible ?

thanks,
Peyman.


I don't know if it is what you're asking, but:

function toboolean(x) return not not x end
print(toboolean(0)) --> true
print(toboolean("")) --> true
print(toboolean(nil)) --> false