lua-users home
lua-l archive

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

Op Thu, 25 Jul 2019 21:54:13 +0200 schreef Coda Highland <>:

Lua's for loops don't have assignment expressions. It's actually rather
noteworthy compared to other programming languages -- neither the
initialization or the increment is a statement.

The C++17 example also looks like something I would NEVER want to write.
There's no compelling reason to put that on one line. Just kick the
initializer out to the previous line, and add braces around it if you
REALLY need the strict scoping.

/s/ Adam

You don't have to write it. :-)

What about the next example?

local function f() return false end

for i = f() and 0 or 40, 42 do
  print( i )

print( i )

-- Jasper