lua-users home
lua-l archive

Re: printf is a crappy language in a crappy language (was Re: [OT] Lua community and Go language)

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


On Mon, Aug 19, 2013 at 10:23 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> But gentlemen, I fear we are drifting off topic, unless someone can
> pull in Lua really quickly.
Here's the C#-style in Lua, without error checking and starting at 1
function tr (fmt,...)
 local args = {...}
 fmt = localize(fmt)
 return (fmt:gsub('{(%d+)}',function(idx)
 idx = tonumber(idx)
 local arg = args[idx]
 return tostring(arg)
 end))
end

AltStyle によって変換されたページ (->オリジナル) /