github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/debuglib/lua/metatables.lua (about)

     1  -- setmetatable
     2  
     3  do
     4      local t = {}
     5      local meta = {__tostring=function() return "meta" end}
     6  
     7      debug.setmetatable(t, meta)
     8      print(t)
     9      --> =meta
    10  
    11      debug.setmetatable(t, nil)
    12      print(t)
    13      --> ~table:.*
    14  
    15      print(pcall(debug.setmetatable, t, false))
    16      --> ~false\t.*: #2 must be a table
    17  
    18      print(pcall(debug.setmetatable, t))
    19      --> ~false\t.*: 2 arguments needed
    20  end