lua-users home
lua-l archive

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


On 8/17/2010 1:48 AM, RJ Russell wrote:
You probably could create a custom build of Lua. I don't know
enough about the code to tell you where though.
Or, you could use this:
function toboolean(v)
   if v=='' or v==0 then return false end
   return v and true or false
end
...
if toboolean(somevalue) then
   --will not run if somevalue is 0 or ''
end
On Mon, Aug 16, 2010 at 10:45 AM, Peyman wrote:

    thanks this function works good but i dont want change 0 and
    null string to true value, there is noway to fix it in Lua, so
    0 and null string have false value by default ?

Peyman, why don't you show us some snippets of code showing how or what you want to test? Lua's definition for true and false testing is very sensible, changing it would be a bad idea especially if more than one person is to work on the source code.

Rather than hiding and abstracting, consider instead clarity. I'm fairly sure that something can be coded in a clear and unambiguous fashion in Lua.

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia