I was reading ROBLOX’s sword source code and noticed this code. I showed the function definition and it’s usage. I understand what it does, but what is this language feature called?
function Create(ty)
return function(data)
local obj = Instance.new(ty)
for k, v in pairs(data) do
if type(k) == 'number' then
v.Parent = obj
else
obj[k] = v
end
end
return obj
end
end
Hmm I think I see what the code is doing now considering you can call functions using function_name{}. So this code below would be identical?
function Create(ty, data)
local obj = Instance.new(ty)
for k, v in pairs(data) do
if type(k) == 'number' then
v.Parent = obj
else
obj[k] = v
end
end
return obj
end