[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why does lua interpreter need = in front of variables?
- From: David Given <dg@...>
- Date: Tue, 16 Oct 2007 10:47:50 +0100
Niklas Frykholm wrote:
[...]
function string:rep(n)
local out = ""
for i=1,n do out = out .. self end
return out
end
Did you know that there already is a string:rep() method?
Also, if you're doing this sort of thing a lot, you should take a look
at table:concat(). Concatenating strings like you're doing here is
extremely slow. This kind of code is considerably faster:
local out = {}
for i = 1, n do out[i] = self end
return table.concat(out, " ")
--
David Given
dg@cowlark.com