lua-users home
lua-l archive

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




On Sun, Feb 11, 2018 at 7:01 PM, Egor Skriptunoff wrote:
On Sun, Feb 11, 2018 at 4:55 PM, albertmcchan wrote:
does comma operator always process from left to right ?

It's easy to check that both vanilla Lua and LuaJIT prepare values from left to right and then assign them from right to left:


More interesting example:

local t = setmetatable({}, {__newindex =
   function(t, k, v)
      print(k)
   end
})

local function f(s)
   print(s)
   return s:upper()
end

t[f("a")], t[f("b")] = f("c"), f("d")

Output:
a
b
c
d
B
A