Hey all!
I wrote a function that will come in handy when printing tables in Lua. Normally, when you call print on a table, it is first tostring-ed into a memory address and looks something like `table: 000002074CD2C070`. How unhelpful! If only there was a better way…
I’ve created a function, repr, that works like Python’s repr. It returns a nice, printable representation of Lua values (strings, numbers, bools, and of course tables). It is designed with two goals in mind: (1) be as close as possible to a literal code representation and (2) be as useful as possible during debugging. Check it out at this GitHub repository, or keep reading this post!
local repr = require(3148021300)
local myTable = {
hello = "world";
score = 5;
isCool = true;
}
print(repr(myTable)) --> {hello = "world", isCool = true, score = 5}