lua-users home
lua-l archive

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


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?
(and for that matter tonumber() for %d/%u, which in turn could call a
__tonumber metamethod...)

-- 
Sent from my toaster.