lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Dec 5, 2010, at 11:45 PM, HyperHacker wrote:

> Something that always bugged me:
>> t={}
>> setmetatable(t, {__tostring = function(t) return "xxx" end})
>> print(t)
> xxx
>> print(('%s'):format(t))
> stdin:1: bad argument #1 to 'format' (string expected, got table)
> 
> Why does string.format not call tostring() on arguments given as %s?

For a patch, see:

http://lua-users.org/lists/lua-l/2006-10/msg00020.html

e