[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __tostring and string.format
- From: Doug Currie <doug.currie@...>
- Date: Mon, 6 Dec 2010 10:22:49 -0500
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