|
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 ) end print( i ) -- Jasper