Skip to content

Instantly share code, notes, and snippets.

@jyrkive
Created June 24, 2018 14:20
Show Gist options
  • Save jyrkive/82f70c709b17b1489895c7b452358461 to your computer and use it in GitHub Desktop.
Save jyrkive/82f70c709b17b1489895c7b452358461 to your computer and use it in GitHub Desktop.
local function dangerous_mutate_table(t, f)
for i, v in ipairs(t) do t[i] = f(v, i) end
end
parent = {}
parent[1] = {}
dangerous_mutate_table(parent, function(v)
v.prop = "asdf"
-- oops, the programmer forgot to return anything here
end)
parent -- is now an empty table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment