[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua strictlessness
- From: Rafis DoctorInfo <rafisganeyev@...>
- Date: Fri, 23 Aug 2013 12:32:46 +0400
Why Lua 5.1 allows to define local variables more than once and not throws error?
local a = 1
local a = a or 2
print(a) -- will print "1"
-- we don't see it, but variable `a` is already defined in function's scope
-- and now we still can define local variable with same name `a`
local a = a or 4
f(3) -- will print "3"