lua-users home
lua-l archive

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


On Thu, 17 Jan 2002 RLake@oxfam.org.uk wrote:

> OK, I'm trying to come to terms with false. I've started going through my
> code looking for places where I assign the result of a boolean expression
> to a table expecting nil to delete the key (since false will no longer do
> that). Maybe I'm the only person with this problem.
>
> [...]
> ej:
>
> if t = function_which_might_return_false(x) then
>      a[x] = t
>   else
>      a[x] = nil
> end

The following code does the trick you want:

  a[x] = function_which_might_return_false(x) or nil

-- Roberto