lua-users home
lua-l archive

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


In the code below I would like to assign 'c' the return value of function
'f', and have c(or the return value of function 'f') compared to the
right-hand side. From the looks of the Lua syntax, you can't do this in Lua.

I get:

error: `)' expected;
  last token read: `=' at line 6 in file `t2.lua'

Can Lua be easily changed to handle this? Just curious, as I sometimes write
similar code in C.

function f()
  return 1
end

c=0
while (c=f()) == 1 do
  print(c)
end

Thanks,
-Lenny