4 ms·
I'm going to be "that guy": -- These are the same: -- ...snip... local function g(x) return math.sin(x) end local g = function (x) return math.sin(x) e
by sharkbot 13y ago
I'm going to be "that guy":
-- These are the same:
-- ...snip...
local function g(x) return math.sin(x) end
local g = function (x) return math.sin(x) end
According to the Lua Reference Manual [1], this example isn't correct. Rather, this is the correct translation:
local function g(x) return math.sin(x) end
local g; g = function (x) return math.sin(x) end
From the manual: "This only makes a difference when the body of the function contains references to f."
[1] http://www.lua.org/manual/5.2/manual.html#3.4.10 http://www.lua.org/manual/5.2/manual.html#3.4.10
- anonymoushn 13y agoWhat this means in practice: > local g=function() print(type(g)) end g() nil > local function g() print(type(g)) end g() function
- tylerneylon 13y agoYou're right; I fixed that part.
- fab13n 13y agoyou also miss a couple of "local newObj" in constructors.