Log In  

It would be very handy if the built in tostr() was able to call the __tostring() metamethod for tables that have it defined. This is easy enough to add in our own code, but feels like it should be default behavior, similar to normal Lua.

P#72548 2020-01-31 23:21

:: dredds

Yes please!

P#72552 2020-02-01 00:00
:: sparr
local _tostr=tostr
local function tostr(n,...)
 if(type(n)=="table" and getmetatable(n) and getmetatable(n).__tostring)return getmetatable(n).__tostring(n,...)
 return _tostr(n,...)
P#72593 2020-02-02 02:57

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2021-04-14 11:57 | 0.011s | 2097k | Q:13