If you add a comma after the assignment statement, why is the lua variable empty?

Code:

local i1 = 1
print(i1)

local i2 = 1,0
print(i2)

local i3 = 1,
print(i3)

result:

1
1
nil

Why is i3 nil instead of 1?

Lua
Mar.24,2021

with a few exceptions, Lua ignores spaces and newline characters. The original code can be represented as
local i3 = 1, and the print (i3)
assignment statement evaluates all its expressions before performing the assignment. So print before the assignment, but in the end i3 is assigned to 1.
local i3 = 1,
print (i3)-- nil
print (i3)-- 1

Menu