0

I followed this page, and got an metamethod __mutate_asn. This is my test code.

local mt = {}
mt.__mutate_asn = function(a, b)
    print(a, b)
    return a + b
end

debug.setmetatable(0, mt)

a = 1
b = 2
a:=b

print(a)

output: 1 2 1 "a" never be changed.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
eale
  • 48
  • 5

1 Answers1

0

You are not mutating any numbers in the statement

a:=b

you are mutating global variables. So, perhaps you need:

setmetatable(_G, mt)
Doug Currie
  • 40,708
  • 1
  • 95
  • 119