lua-users home
lua-l archive

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


x[1] is {} which, evaluated as a boolean, is true in Lua. The only false objects are `false` and `nil`, unlike other languages such as Python.

-- 
Pierre Chapuis

On Sun, Apr 30, 2023, at 12:56, Heqing HUANG wrote:
However, since x[1] is empty, should it be false and directly terminate the loop?



On Sun, Apr 30, 2023 at 6:48 PM Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
The main loop below never changes the value of x[1] and never creates
garbage (numbers are not objects).

while x[1] do   -- repeat until GC
  local a = A -- create garbage
  A = A+1
end