How do we change the way print displays a table
问题 Assuming I have a piece of code such as the following aTable = {aValue=1} aTable_mt = {} print(aTable) What must I do to make Lua print something like aTable current aValue = 1 as opposed to table: 0x01ab1d2 . So far I've tried setting the __tostring metamethod but that doesn't seem to be invoked by print . Is there some metamethod I've been missing or does the answer have nothing to do with metamethods? 回答1: __tostring works: aTable = {aValue=1} local mt = {__tostring = function(t) local